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

Usergroup conditionals

Discussion in 'XenForo Development Discussions' started by Matthew Hawley, Aug 1, 2013.

  1. Matthew Hawley

    Matthew Hawley Well-Known Member

    Are there any conditionals so I can view a certain user group?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    What do you mean "view a certain user group"?

    If you're talking about hiding/showing content to specific usergroups, you can do this:

    Code:
    <xen:if is="{xen:helper ismemberof, $visitor, 999}">
          Visitor is member of usergroup ID 999
    </xen:if>
     
  3. Matthew Hawley

    Matthew Hawley Well-Known Member

    No, I want to show a staff list sorted by user groups. So I need conditionals to show the user groups.
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    That's not quite what you asked for, but ok.

    It will save you a lot of time and frustration if you just explain in advance what you're wanting to do in detail.

    Using the Notable Members list as an example, the template has this:

    Code:
                    <xen:foreach loop="$staff" value="$user">
                        <li><xen:avatar user="$user" size="s" text="{$user.username}" class="Tooltip" title="{$user.username}" /></li>
                    </xen:foreach>
    So you could copy that several times and add a very similar conditional to what I used above for each usergroup you want to show:

    Code:
                   <div class="staffHeader">Moderating Staff</div>
                    <xen:foreach loop="$staff" value="$user">
                       <xen:if is="{xen:helper ismemberof, $user, 4}">
                            <li><xen:avatar user="$user" size="s" text="{$user.username}" class="Tooltip" title="{$user.username}" /></li>
                       </xen:if>
                    </xen:foreach>
    So, something like that.
     
    Matthew Hawley likes this.
  5. Matthew Hawley

    Matthew Hawley Well-Known Member

    How would I add this just to the staff page on notable members?
     
  6. Chris D

    Chris D XenForo Developer Staff Member

    In the member_notable template, find this:

    Code:
                    <xen:foreach loop="$staff" value="$user">
                        <li><xen:avatar user="$user" size="s" text="{$user.username}" class="Tooltip" title="{$user.username}" /></li>
                    </xen:foreach>
    Modify as appropriate.
     

Share This Page