Is there a reason to use hascontent instead of just an is check?

Jaxel

Well-known member
Code:
<xen:if hascontent="true">
    <ul class="adminList">
        <xen:contentcheck>
        <xen:foreach loop="$admins" value="$user">
            <li><xen:username user="$user" rich="true" /></li>
        </xen:foreach>
        </xen:contentcheck>
    </ul>
</xen:if>
VS
Code:
<xen:if is="{$admins}">
    <ul class="adminList">
        <xen:foreach loop="$admins" value="$user">
            <li><xen:username user="$user" rich="true" /></li>
        </xen:foreach>
    </ul>
</xen:if>

Why choose the content check instead of just doing the if is?
 
I used this for replacing the moderatorBar with a generic userBar. It shows the bar if there is content to be shown, regardless if regular user or admin/moderator.
 
Well, in the example you quoted, not using hascontent would duplicate conditionals that you have to manage. One to show if at least one is present, and then once again for each individual item. hascontent reduces that so you only have to manage each inner conditional once.
 
Top Bottom