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

Conditional Statements

semprot

Active member
Changed to
Code:
<xen:if is="!in_array({$category.node_id}, array(178, 179))">
still not working right
Are you sure the variable is correct / node_id exists in that template?
Try to var dump it in local installation (just in case your nodes in live site is too many).

PHP:
{xen:helper dump, $category}
 

sgr

Active member
I want to show my adsense code to unregistered users on all pages except the error page and the member view page. So I wrote this conditional:

Code:
<xen:if is="!{$visitor.user_id} AND ({$contentTemplate} != 'error' OR {$contentTemplate} != 'member_view')">
The OR and braces don't work when there's an AND as well.

How do I get something like X AND (Y OR Z) in one conditional statement?


EDIT:

Just tried with in_array. I had a misconception that it's only for int values like node_id, user_id, etc. It appears to be working correctly:

Code:
<xen:if is="!{$visitor.user_id} AND !in_array({$contentTemplate}, array('member_view', 'error')">
I hope this is the correct and recommended way of using such a conditional?
 
Last edited:
How would I hide content only if a certain person was the author of said content?
For instance, if the content is created by an Admin and I wanted to hide the name of the content author.
 

Mike Edge

Well-known member
I'm using this, but it isn't working. Confirmed category is 498 too.

Code:
<xen:if is="{$category.node_id} == 498">
testing
</xen:if>
If forum_view the correct template?
 
Last edited:

JordanH

Well-known member
Is there any type of " If super admin" statement?
There's a certain thing in the admin area that I don't want normal admins being able to access that is not permission based. So I want to edit the admin templates to include an if statement to say if they are a super admin to show.

Edit:
Nvm found it:
<xen:if is="{$admin.is_super_admin}">
or
<xen:if is="{$visitor.is_super_admin}">
Edit 2:
That didn't seem to work. Both hides the content to both admins and super admins o_O
Since there is only 2 Super admins, I'm doing
<xen:if is="{$visitor.user_id} == x">
And putting our user IDs instead
 
Last edited:

eva2000

Well-known member
I was wondering if anyone can point in the right direction for showing code/ads in sidebar area but only on category pages and not on thread pages or conversation/private pages ?

tried something like this in my template which is called from bd widget advance html
Code:
<xen:if is="!{xen:helper ismemberof, $visitor, 5} AND !in_array({$contentTemplate}, array('member_view', 'message_page', 'error', 'search_form', 'search_form_post', 'search_form_profile_post', 'search_results', 'register_form', 'register_facebook', 'register_twitter', 'register_google', 'login', 'login_two_step', 'error_with_login', 'contact'))
">
CODE
</xen:if>
doesn't seem to be working though
 
Last edited:

RoldanLT

Well-known member
I was wondering if anyone can point in the right direction for showing code/ads in sidebar area but only on category pages and not on thread pages or conversation/private pages ?

tried something like this in my template which is called from bd widget advance html
Code:
<xen:if is="!{xen:helper ismemberof, $visitor, 5} AND !in_array({$contentTemplate}, array('member_view', 'message_page', 'error', 'search_form', 'search_form_post', 'search_form_profile_post', 'search_results', 'register_form', 'register_facebook', 'register_twitter', 'register_google', 'login', 'login_two_step', 'error_with_login', 'contact'))
">
CODE
</xen:if>
doesn't seem to be working though
https://xenforo.com/community/resources/conditional-statements.1604/

26. How can I show content in a specific category?
<xen:if is="{$category.node_id} == x">
This content will show in category x


</xen:if>
Note that in order for this to work, you must have categories set as pages in the ACP -> Options -> Node & Forum List: Create Pages for Categories.
Additionally, to ensure the category ID is available in the ad_* templates, the category_view template must be edited and the following code added: <xen:container var="$category.node_id">{$category.node_id}</xen:container>
 

Joeychgo

Well-known member
Have I done something wrong here ? The conditional doesn't seem to work to block the ad from being seen by this usergroup (usergroup 21)


Code:
<xen:if is="!{xen:helper ismemberof, $visitor, 21}">
<center>
<!-- BEGIN SECURE JS TAG - 300x250 -->
<!--DO NOT MODIFY-->
<SCRIPT SRC="https://secureads.digitalthrottle.com/ttj?id=3106679&cb=[CACHEBUSTER]&referrer=forabodiesonly.com" TYPE="text/javascript"></SCRIPT>
<!-- END TAG -->
</center>
</xen:if>