How to count the number of grouped attachments for a page in kentico 9?

329 Views Asked by At

I want to show a list of attachments, but only if there are any. If not, hide the containing div. How do I do this? Thanks!

2

There are 2 best solutions below

5
On

Assuming that you are showing a list of attachments on the current document, you can get the number of grouped attachments with a macro:

{% CurrentDocument.GroupedAttachments["DocumentsAttached"].Count %}

DocumentsAttached would be the name of the field that contains the attachments.

On your attachments list webpart, you can set the value of the visibility field to the following macro:

{% CurrentDocument.GroupedAttachments["DocumentsAttached"].Count > 0 %}
0
On

I ended up accomplishing this with a custom query and function.