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

XF 1.1 Too Many Conditions In "If" Condition. Help Me Optimize It.

TheBigK

Well-known member
#1
I'm using following code to display adsense on specific pages -

Code:
<xen:if is="{$contentTemplate} !== 'forum_list' AND {$contentTemplate} !== 'register_form' AND {$contentTemplate} !== 'EWRatendo_Monthly'  AND {$contentTemplate} !== 'member_list' AND {$contentTemplate} !== 'online_list' AND {$contentTemplate} !== 'news_feed_page_global'">
It does the work, but is there a better or graceful way of passing too many conditions to "if"?
 
S

Syndol

Guest
#2
Why not do the logic in PHP and then pass a boolean variable such as $isMyTemplate, then all you have to do is:
<xen:if is="{$isMyTemplate}">
 

TheBigK

Well-known member
#3
Why not do the logic in PHP and then pass a boolean variable such as $isMyTemplate, then all you have to do is:
<xen:if is="{$isMyTemplate}">
Well, I'm not at all familiar with programming. Could you tell me how can I group all these conditions?

What I'm trying to achieve is -

<xen:if (conditions) >

-> Display Adsense Code

</if>
 
S

Syndol

Guest
#4
You will need an ad-on in order to get at the hooks of the different ad positions.
Otherwise, instead of excluding too many names (!=) just check for the ones you want (==) which might be a shorter if statement.
 

TheBigK

Well-known member
#5
Oh well, my question is actually very simple. Can this 'if' thing be re-written in a better way or the one I've written in the first post is the only way to write that 'if' condition?