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

Seperating primary and secondary usergroups in templates possible?

Luxus

Well-known member
#1
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.
 

Luxus

Well-known member
#3
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.
 
S

Syndol

Guest
#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}" />
 

Luxus

Well-known member
#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.
 
S

Syndol

Guest
#6
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>