Share » Forums » Setup & design » Test for empty array

Test for empty array

Test for empty array

Wednesday 31 October 2007 7:12:26 pm - 3 replies

Author Message

Łukasz Serwatka

Wednesday 31 October 2007 11:27:46 pm

Hi Paul,

You can test it with count() tpl operator

{* Example 1 *}
{def $my_array=array()}

{if $my_array|count()}

{else}

{/if}

{* Example 2 *}

{if $my_array|count()|gt(0)}

{else}

{/if}

Hope that helps.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

André R.

Thursday 01 November 2007 2:33:30 am

Doesn't empty arrays evaluate to false ??
like this:

{if $my_array}
{else}
{/if}

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

paul bolger

Thursday 01 November 2007 4:07:21 pm

Thanks, both work.

Paul Bolger

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu