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

Help with showing content to certain usergroups

Discussion in 'XenForo Questions and Support' started by gldtn, Jun 30, 2011.

  1. gldtn

    gldtn Well-Known Member

    Hello guys, I'm trying to show a certain piece of code using this:

    Code:
    <xen:if is="{xen:helper ismemberof, $user, x} AND {$user.is_admin} OR {$user.is_moderator}">
    
    CODE HERE
    
    </xen:if>
    But I get:
    Any ideas?
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Which template? Apparently $user isn't available.

    If you want to check the current logged in user then use $visitor.
     
  3. gldtn

    gldtn Well-Known Member

    PAGE_CONTAINER, I what to show the code only to X usergroup, admins, and moderator..
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    In that case use $visitor instead of $user.
     
  5. gldtn

    gldtn Well-Known Member

    That worked, but
    {xen:helper ismemberof, $visitor, x}

    X usergroupd is not seeing what is suppose to display!

    Only admins and moderators
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Change your condition to this:

    Code:
    <xen:if is="{xen:helper ismemberof, $visitor, x} OR {$visitor.is_admin} OR {$visitor.is_moderator}">
    
    </xen:if>
    
    You were using AND which is not correct for what you want.
     
    gldtn likes this.
  7. gldtn

    gldtn Well-Known Member

    Thank you very much!
     
  8. giorgino

    giorgino Well-Known Member

    Hi Jake, in your opinion, why this conditional don't work? :(

    Code:
    <xen:if is="{xen:helper ismemberof, $user, 39}">
        <span style="padding-left:5px;"><img src="styles/immobilio/rank/01.png"></span>
    <xen:elseif is="{xen:helper ismemberof, $user, 40}" />
        <span style="padding-left:5px;"><img src="styles/immobilio/rank/02.png"></span>
    <xen:elseif is="{xen:helper ismemberof, $user, 36}" />
        <span style="padding-left:5px;"><img src="styles/immobilio/rank/03.png"></span>
    <xen:elseif is="{xen:helper ismemberof, $user, 35}" />
        <span style="padding-left:5px;"><img src="styles/immobilio/rank/04.png"></span>
    <xen:elseif is="{xen:helper ismemberof, $user, 41}" />
        <span style="padding-left:5px;"><img src="styles/immobilio/rank/05.png"></span>
    <xen:elseif is="{xen:helper ismemberof, $user, 42}" />
        <span style="padding-left:5px;"><img src="styles/immobilio/rank/06.png"></span>
    <xen:else />
        <span style="padding-left:5px;"><img src="styles/immobilio/rank/00.png"></span>
    </xen:if>
     
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    In what template?

    That code looks to be showing different images based on usergroup. The elseif's mean it will only ever show one image regardless of how many ranks the user qualifies for.
     
  10. giorgino

    giorgino Well-Known Member

    Exactly.
    The code is inserted in message_user_info and show a different progress bar based on user group.

    My idea was a case-of logic structure and not a mere if-then, but I don't found switch or case in xenforo syntax...
    How can I do?

    Thanks :)
     
  11. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Did you intend to show multiple images for individual users? Try this:

    Code:
    <xen:if is="{xen:helper ismemberof, $user, 39}">
        <span style="padding-left:5px;"><img src="styles/immobilio/rank/01.png"></span>
    </xen:if>
    
    <xen:if is="{xen:helper ismemberof, $user, 40}">
        <span style="padding-left:5px;"><img src="styles/immobilio/rank/02.png"></span>
    </xen:if>
    
    <xen:if is="{xen:helper ismemberof, $user, 36}">
        <span style="padding-left:5px;"><img src="styles/immobilio/rank/03.png"></span>
    </xen:if>
    
    <xen:if is="{xen:helper ismemberof, $user, 35}">
        <span style="padding-left:5px;"><img src="styles/immobilio/rank/04.png"></span>
    </xen:if>
    
    <xen:if is="{xen:helper ismemberof, $user, 41}">
        <span style="padding-left:5px;"><img src="styles/immobilio/rank/05.png"></span>
    </xen:if>
    
    <xen:if is="{xen:helper ismemberof, $user, 42}">
        <span style="padding-left:5px;"><img src="styles/immobilio/rank/06.png"></span>
    </xen:if>
    
     
  12. giorgino

    giorgino Well-Known Member

    No Jack, I need to display one badge for each specific user group.

    I can do this with a series of if like you've suggested.

    My intention is to find a logic structure more sophisticated like a case in php language for instance.
     
  13. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Oh. There is no such structure for template syntax.
     
  14. giorgino

    giorgino Well-Known Member

    Thank you Jake :) I'll proceed with if syntax
    I don't understand the use of elseif o_O
     

Share This Page