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

XF 1.4 User-specific content - conditional statement

rugk

Active member
#1
I'm trying to make a template where I want to display different values depending on the user group.

So basically this is the part of the template which fails:
HTML:
  <xen:if is="{$visitor.is_admin}">
    <p>admin</p>
  <xen:elseif is="{$visitor.is_moderator}">
    <p>mod</p>
  <xen:elseif is="{$visitor.user_id}">
    <p>registered</p>
  <xen:else />
    <p>visitor</p>
  </xen:if>
XenForo always reports there is an error on line 9, which is the last line here. But I have no idea what's wrong with this line...
 

rugk

Active member
#3
Okay, I tried it this way:
HTML:
  <xen:if is="{$visitor.is_admin}" />
    <p>admin</p>
  <xen:elseif is="{$visitor.is_moderator}" />
    <p>mod</p>
  <xen:elseif is="{$visitor.user_id}" />
    <p>registered</p>
  <xen:else />
    <p>visitor</p>
  </xen:if>
But XenForo still complains about a syntax error in line 9.
 

rugk

Active member
#5
Ah yes thanks. Didn't noticed I added one there. Thanks.

This way it works:
HTML:
  <xen:if is="{$visitor.is_admin}">
    <p>admin</p>
  <xen:elseif is="{$visitor.is_moderator}" />
    <p>mod</p>
  <xen:elseif is="{$visitor.user_id}" />
    <p>registered</p>
  <xen:else />
    <p>visitor</p>
  </xen:if>