• 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.

Sheldon

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

SneakyDave

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

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

Brogan

XenForo moderator
Staff member
#7
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

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