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

Discussion in 'Styling and Customization Questions' started by rugk, Aug 4, 2015.

  1. rugk

    rugk Active Member

    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...
     
  2. Martok

    Martok Well-Known Member

    The xen:elseif statements need a / before the closing >
     
    rugk likes this.
  3. rugk

    rugk Active Member

    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.
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    rugk likes this.
  5. rugk

    rugk Active Member

    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>
     

Share This Page