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

XF 1.3 Conditional Help... Usergroups.

Discussion in 'Styling and Customization Questions' started by Sheldon, Jun 18, 2014.

  1. Sheldon

    Sheldon Well-Known Member

    Alright, I have this:

    Code:
    <div class="
    <xen:if is="{xen:helper ismemberof, $visitor, 6}">backImg2 </xen:if>
    <xen:if is="{xen:helper ismemberof, $visitor, 7}">backImg3 </xen:if>
    <xen:if is="{xen:helper ismemberof, $visitor, 1}">backImg4 </xen:if>
    ">
    Then some more code...

    Then the closing <div>

    Obviously not working, and I have attempted every iteration I could run across.

    What I want is say...

    Usergroup 6 <div class="backImg2">
    Usergroup 7 <div class="backImg3">
    Usergroup 8 <div class="backImg4">

    I want all visitors to see whatever that usergroup has representing in the "backImg" part, but when the user chooses the Usergroup they are in, the div class is styled differently.

    I'm tired.
     
  2. SneakyDave

    SneakyDave Well-Known Member

    Did this work or is there more to the div that you need to add?

    Code:
    <xen:if is="{xen:helper ismemberof, $visitor, 6}">
        <div class="backImg2">
    <xen:elseif is="{xen:helper ismemberof, $visitor, 7}
       <div class="backImg3">
    <xen:elseif is="{xen:helper ismemberof, $visitor, 8}
        <div class="backImg4">
    <xen:else />
        <div class="somedefault">
    </xen:if>
    
    </div>
    
    
     
    Sheldon likes this.
  3. Sheldon

    Sheldon Well-Known Member

    No... that didn't work... Meh.
     
  4. Sheldon

    Sheldon Well-Known Member

    Progress... I can get it to display differently now, you set me on the correct path.

    Code:
    <xen:if is="{xen:helper ismemberof, $visitor, 6}">
        <div class="backImg2">
    <xen:elseif is="{xen:helper ismemberof, $visitor, 7} "/>
       <div class="backImg3">
    <xen:elseif is="{xen:helper ismemberof, $visitor, 8} "/>
        <div class="backImg4">
    <xen:else />
        <div class="backImg1">
    </xen:if>      
    Now I am at this... Usergroup 8 logged in, I ALWAYS see backImg4, regardless.
    Usergoup 6 logged in, I see backImg2 always.
     
  5. Sheldon

    Sheldon Well-Known Member

    Got it...

    change $visitor to $user

    Appreciate the kick in the right direction @SneakyDave (y)
     
    SneakyDave likes this.
  6. SneakyDave

    SneakyDave Well-Known Member

    Oh man. That $user and $visitor difference always gets me
     
  7. Brogan

    Brogan XenForo Moderator Staff Member

    Depending on the template being worked with, you may need to use $user instead of $visitor; $visitor is always the record for the current logged in user, $user is the record being processed (e.g. message author, member list, list of online users, etc.).
     
    Sheldon and SneakyDave like this.
  8. Sheldon

    Sheldon Well-Known Member

    Yeah, I needed $user in message_user_info and $visitor in sidebar_user_panel.

    My issue was my brain was fried and I couldn't think to get the first part of the conditionals to work. Dave threw me in right direction though. All sorted.
     
    SneakyDave likes this.

Share This Page