Skip to the content
Documentation

Test for empty array

No ratings yet

To test for an empty array (to add a title to a fetched list, conditional on the list containing items, for instance) you can use either of these:

{if $my_array|count()|gt(0)}
<h2>My Title</h2>
{else}
{* Nothing! *}
{/if}

or

{if $my_array}
<h2>My Title</h2>
{else}
{* Nothing! *}
{/if}