• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.5 How do I determine the size of an array in a template?

Stuart Wright

Well-known member
I have a review with no Pros or Cons
and the template is supposed to only display the Pros and Cons if there are any.
<xen:if is="{$content.pros} AND {$content.cons}">
yet the Pros and Cons are displayed resulting in the display of the headers and nothing else.
Should I change the conditional to test for the number of elements in the arrays?
Last edited:


XenForo moderator
Staff member
You can dump it to see what it contains.
{xen:helper dump, $content.pros}
You may need to use an exclusive condition or value rather than just checking for the presence of the param.


XenForo moderator
Staff member
Yes, as it's not NULL, it's meeting the terms of the condition.

You can likely just edit the condition to add > 0 for both, although that would require both to be > 0 in order for that to evaluate.

Chris D

XenForo developer
Staff member
Ideally the back end code would be handling that specifically. The easiest way to do that is just run the array through array_filter (with no function argument) before it is saved and it will automatically strip out entries from the array which are "falsey".
Last edited: