Seperating primary and secondary usergroups in templates possible?

Luxus

Well-known member
You can add a usergroup conditional in templates with this
Code:
<xen:if is="{xen:helper ismemberof, $user, 4}">something</xen:if>

4 is the usergroup id. But does xenforo's template syntax make a difference between primary and secondary usergroups? What I want is a conditional for primary usergroups only, completly ignoring secondary usergroups.
 
Thanks, but strange is, usergroup ID 4 is for admins here and with the conditional above all registered users get administrator rank images. My code I used is this:
Code:
<!-- Start User Ranks -->
<xen:if hascontent="true">
<ul class="userRank">
<xen:contentcheck>
<xen:if is="{$visitor.user_group_id} == 4">
<li class="administrator"></li>
</xen:if>
<xen:if is="{xen:helper ismemberof, $user, 5}">
<li class="superModerator"></li>
</xen:if>
<xen:if is="{xen:helper ismemberof, $user, 6}">
<li class="moderator"></li>
</xen:if>
</xen:contentcheck>
</ul>
</xen:if>
<!-- End User Ranks -->

It's in the message_user_info template. I can't explain it, because registered users have the ID of 2 and not 4.
 
That's because in my example I used $visitor which is the person viewing the page. What you want is $user
Not sure if you are going for multiple css classes but if not you may want to consider using elseif statements such as <xen:elseif is="{xen:helper ismemberof, $user, 5}" />
 
$user does the trick, thanks :)
I tried to use xen:elseif is but the server isn't responding when I use it. I am using TMS and and apparently it takes longer to build a template if it contains xen:elseifs. I tried to increase the execution time or how it's called, but to no effect. Well, at least it's working now, regardless of how.
 
There should be no change in execution time.
Try the following (not tested):
HTML:
<xen:if hascontent="true">
    <ul class="userRank">
    <xen:contentcheck>
        <xen:if is="{$user.user_group_id} == 4">
            <li class="administrator"></li>
        <xen:elseif is="{xen:helper ismemberof, $user, 5}" />
            <li class="superModerator"></li>
        <xen:elseif is="{xen:helper ismemberof, $user, 6}" />
            <li class="moderator"></li>
        </xen:if>
    </xen:contentcheck>
    </ul>
</xen:if>
 
Top Bottom