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

How do I properly make the sidebar display only for specific usergroups?

Discussion in 'XenForo Development Discussions' started by EQnoble, Feb 15, 2011.

  1. EQnoble

    EQnoble Well-Known Member

    I have successfully added a sidebar Item to the thread_view for display when viewing threads and now was wondering what is the correct way to set the condition to display only if visitor is x,y,or z usergroupID

    this is what I basically added

        <xen:include template="sidebar_xx_item" />
    What kind of conditions and how can it be done is basically what I'm asking of anyone that can offer the help.
  2. Shadab

    Shadab Well-Known Member

    Bob and EQnoble like this.
  3. EQnoble

    EQnoble Well-Known Member

    This works just fine...THANK YOU!

    Is there something similar for a specific userID as well...my brain is saying something like $user, 2 but I can't think of how to put that together.
  4. Shadab

    Shadab Well-Known Member

    The user ID is stored in the $visitor array, with the key: user_id.
    So you can try...
    <xen:if is="{$visitor.user_id} == N">
        <!-- Stuff -->
    EQnoble likes this.
  5. EQnoble

    EQnoble Well-Known Member

    Works just fine there sir! Note to anyone trying it...if you don't supply it with an actual userID and leave such as the example N upon saving xenforo will throw you back an error..don't fret just supply your user id ( I used 1 for admin ) and save and all should be fine.

    Thanks again Shedab
  6. Shadab

    Shadab Well-Known Member

    You're welcome.

    And yes, "N" is to be replaced with either an integer or a variable containing an integer;
    to work correctly.
  7. EQnoble

    EQnoble Well-Known Member

    Hey while I got yah with all the answers here :), is there a similar snippit I could use for forumID ?
  8. Shadab

    Shadab Well-Known Member

  9. EQnoble

    EQnoble Well-Known Member

  10. Tilkißey

    Tilkißey Well-Known Member

    u can use for forumIDs this code, an example in thread_view template ( i use in that )
    <xen:if is="in_array({$forum.node_id}, array(5,7,8,9,26))">
    u can edit this code for ur main target
    <xen:if is="in_array({$visitor.user_id}, array(1,2,3,54,645645))">
    via using this codes, u will add less codes, not code crowding (sorry my English =) )
    EQnoble and James like this.

Share This Page