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

List of if conditions

Discussion in 'XenForo Questions and Support' started by jgas, Jan 20, 2011.

  1. jgas

    jgas Active Member

    Hi,
    could you please write a list of all the conditions we can use on xenforo?

    Mainly, i need the conditions is registred, is unregistred, is thread x, is forum y, is usegroup z!

    Thanks! ;)
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Registered and unregistered:

    http://xenforo.com/community/threads/1-0-0-b1-member-guest-template-condition.5566/

    Group checking:

    http://xenforo.com/community/threads/usergroup-checking-in-the-templates.9447/

    Threadid checking (works in the thread_view template):

    Code:
    <xen:if is="{$thread.thread_id} == 1">
    	test
    </xen:if>
    
    Forumid checking (works in forum_view):

    Code:
    <xen:if is="{$forum.node_id} == 2">
    	test
    </xen:if>
    
     
    Brandon Sheley and jgas like this.
  3. jgas

    jgas Active Member

  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Code:
    <xen:if is="{$visitor.message_count} == 0">
    	Welcome, new user! Please introduce yourself here!
    </xen:if>
    
     
    jgas likes this.
  5. dieketzer

    dieketzer Well-Known Member

    i nominate jake to author a sticky post.
     
  6. Mikey

    Mikey Well-Known Member

    dieketzer likes this.
  7. Brogan

    Brogan XenForo Moderator Staff Member

    dieketzer likes this.
  8. faeronsayn

    faeronsayn Well-Known Member

    Wondering how to "NOT" display things in certain forums...

    I know how to do that, but the thing is how do I use it in page container? Since I've heard that you can only use it in "forum_view".

    By the way I am talking about this condition...

    <xen:if is="{$forum.node_id} == 2"> test </xen:if>

    So here is the deal, I need to display ads globally, but I do not want to display them in certain forums, since they would most likely violate the ad's TOS, thats why I am trying to use template conditions so they are not displayed on these pages.

    So if Anyone has an idea of how to do this please let me know. Again I need to use this in Page_Container, and in thread_view I think.
     
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    See this post:

    http://xenforo.com/community/threads/language-attribute.15249/#post-200171

    The instructions are the same for you, except at the end when you edit PAGE_CONTAINER. Use this code:

    Code:
    <xen:if is="!in_array({$forumId}, array(1,2,3))">
    	AD CODE HERE
    </xen:if>
    
    This condition will make it so the ad code does not display in forums 1, 2, and 3. Specify the node_ids of your excluded forums.
     
    MrC and faeronsayn like this.
  10. faeronsayn

    faeronsayn Well-Known Member

    That is perfect, its working for me, just another question how would you be able to do this with categories.

    Also, the threads within these forums are still displaying the ads,...

    How do you make it so the threads within the forums that I do not want ads displayed do not display ads as well.
     
  11. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    When you edit forum_view and thread_view, use this code instead to pass the parent_node_id:

    Code:
    <xen:container var="$forumId">{$forum.parent_node_id}</xen:container>
    
    Now you can specify the immediate parent_node_id in PAGE_CONTAINER. 1,2,3 would then specify the node_ids of the categories you want to exclude. All forums that are immediate children of the parent_node_id will be excluded from showing ads.

    Make sure you edited both forum_view and thread_view, per that post:

    http://xenforo.com/community/threads/language-attribute.15249/#post-200171
     
    faeronsayn likes this.
  12. faeronsayn

    faeronsayn Well-Known Member

    As for this

    Code:
    <xen:container var="$forumId">{$forum.parent_node_id}</xen:container>
    
    I didn't really need the parent part, so I took that out and its working with categories now.

    I just used this ..

    Code:
    <xen:container var="$forumId">{$forum.node_id}</xen:container>
    
    As for the thread_view and forum_view thats working great now thanks.

    Just another question, I also have ads displaying in threads, right after the first message.

    This is in the "message" template, and I pretty much want to exclude it from some of the forums that violate the AD tos, pretty much what we did with Page_Container, I just tried the same thing that I did with page_contrainer, and it didn't work. So if you could please help me with that part as well.

    Thank you so much for the help by the way.
     
  13. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    In the message template you can use this condition:

    Code:
    <xen:if is="!in_array({$thread.node_id}, array(1,2,3))">
    	AD CODE HERE
    </xen:if>
    
     
    faeronsayn likes this.
  14. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  15. Floris

    Floris Guest

    Why would you want to hide a category? Do you mean it's individual category row, but still show the forum nodes themselves? Or the particular node?
    Doesn't xenforo node manager already have an option [x] display in node list?
     
  16. Floris

    Floris Guest

    Very cool! Thanks for explaining.
     
  17. mrGTB

    mrGTB Well-Known Member

    Jake, how can I combine that above with another conditional, so the ads only get displayed to guests only in one forum. I know the guests conditional, but I'm not sure how to combine them both into one, rather than using two separate conditionals.
     
  18. Brogan

    Brogan XenForo Moderator Staff Member

  19. mrGTB

    mrGTB Well-Known Member

    Thank for that! I already did read that FAQ you link back to, but I still don't really get how you put them together.
     
  20. Brogan

    Brogan XenForo Moderator Staff Member

    Look up... ^
     

Share This Page