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

List of if conditions

jgas

Active member
#1
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! ;)
 

Jake Bunce

XenForo moderator
Staff member
#2
Mainly, i need the conditions is registred, is unregistred, is thread x, is forum y, is usegroup z!
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>
 

faeronsayn

Well-known member
#8
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.
 

Jake Bunce

XenForo moderator
Staff member
#9
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.
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.
 

faeronsayn

Well-known member
#10
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.
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.
 

Jake Bunce

XenForo moderator
Staff member
#11
That is perfect, its working for me, just another question how would you be able to do this with categories.
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.

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.
Make sure you edited both forum_view and thread_view, per that post:

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

faeronsayn

Well-known member
#12
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>
Make sure you edited both forum_view and thread_view, per that post:

http://xenforo.com/community/threads/language-attribute.15249/#post-200171
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.
 

Jake Bunce

XenForo moderator
Staff member
#13
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.
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>
 

Jake Bunce

XenForo moderator
Staff member
#14
F

Floris

Guest
#15
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?
 

mrGTB

Well-known member
#17
Registered and unregistered:


Forumid checking (works in forum_view):

Code:
<xen:if is="{$forum.node_id} == 2">
test
</xen:if>
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.
 

mrGTB

Well-known member
#19
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.