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

Groups conditional in template

Discussion in 'XenForo Questions and Support' started by najaru, Oct 7, 2010.

  1. najaru

    najaru Active Member

    Hi.
    If i want to insert a html code in template, and i want that this code is visible ONLY at 1 o 2 groups, what code i have to use?

    thanks
     
  2. Lawrence

    Lawrence Well-Known Member

    <xen:if is="{$visitor.user_group_id} == '2'">

    </xen:if>
     
    MentaL likes this.
  3. MentaL

    MentaL Active Member

    Awesome lawrence, would you happen to know how to set a condition for say if the post is number 1, that way we can use this code for guests and is post 1 thus being useful for an advertisement banner.

    Cheers.
     
    najaru likes this.
  4. Lawrence

    Lawrence Well-Known Member

    It's $visitor.user_group_id

    The $user was for a foreach loop.

    For post number:

    <xen:if is="!{$post.position}">

    </xen:if>

    The first post is position 0. If you would like to check for the 3rd post, try this:

    <xen:if is="{$post.position} == '2'">

    </xen:if>
     
  5. najaru

    najaru Active Member

    many thanks at both of you ;)
     
  6. Michael

    Michael Active Member

    Sorry to bump this up but I cannot get your conditional to work in thread_view, should this one work in thread view? I am using it just after
    Code:
    <xen:edithint template="attached_files" />
        </ol>
     
  7. Lawrence

    Lawrence Well-Known Member

    I tested it in thread_view, placed at the very bottom of the template just above these two closing tags:

    </xen:set>
    </xen:include>

    for example:

    Code:
    <xen:if is="!{$post.position}">
    My advertisement code here that will display right after post #1
    </xen:if>
    
        </xen:set>
        
    </xen:include>
    
     
    Michael likes this.
  8. Michael

    Michael Active Member

    Im not seeing it in the source using this:

    Code:
    <xen:if is="{$visitor.is_admin}">
    <xen:if is="!{$post.position}">
    WOWOWOW
    </xen:if>
    </xen:if>
    
    and thats like so in the thread_view template:

    Code:
    <xen:include template="share_page">
        <xen:set var="$url">{xen:link 'canonical:threads', $thread}
    <xen:if is="{$visitor.is_admin}">
    <xen:if is="!{$post.position}">
    WOWOWOW
    </xen:if>
    </xen:if>
    </xen:set>
    </xen:include>
    
    I also tried it after the last closing tags without it showing in the source.

    EDIT: All is well now, I needed to use it after the include post code for it to work as needed.

    Thank you
     

Share This Page