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

XF 1.1 Xenforo conditionals question

B

bogus

Guest
#1
I remember Brogan had opened a Thread where all the xen:if conditionals where listed. I cant find that Thread anymore, also on Help Page i dont see it.

What i am trying to do is to hide all Google Adsense on xenporta index Page, so i guess i need something like "if index page -> hide google ads -> else show Layer Ad"

Maybe anyone knows where that Thread is hiding ;) Or much better anyone can help me with the Ads. Cheers ;9
 
B

bogus

Guest
#4
Just tried it and it hides the Ads on the Forum Page too...

I use "Set as Index Controller"
 

Chris D

XenForo developer
Staff member
#5
<xen:if is="{$controllerName} == 'EWRporta_ControllerPublic_Portal'">
Hide Google Ads
<xen:else />
Show Layer Ad
</xen:if>

My mistake.

I believe the correct controller is EWRporta_ControllerPublic_Portal
 
B

bogus

Guest
#6
Edit: Works ;) Thank you so much.
Its <xen:if is="{$controllerName} != 'EWRporta_ControllerPublic_Portal'">
Dont know why. But it is working at the end.
 

Chris D

XenForo developer
Staff member
#7
We're both right :p Though my example was slightly misleading. My example in reality should look like this:

Code:
<xen:if is="{$controllerName} == 'EWRporta_ControllerPublic_Portal'">
<xen:else />
Ad Code
</xen:if>
If it's the Portal it displays nothing. Anything else it displays the code.

I'm guessing yours looks something like:

Code:
<xen:if is="{$controllerName} != 'EWRporta_ControllerPublic_Portal'">
Ad Code
</xen:if>
So if it is not the Portal it displays the ad code.

Both work, so either is fine. But just so you know the difference :)
 
B

bogus

Guest
#8
Is it possible to add two restrictions?

I dont want Google Ads to be displayed on the Portals Page which is solved (thanks a lot) and none on the Login Page, because Google Adsense seems not to like Login Pages. I just get 2 blue boxes.
So, i could add the Adlayers there?
Thanks for every help
 

Chris D

XenForo developer
Staff member
#9
Based on the previous code which worked for you, this should now work.

<xen:if is="{$controllerName} != 'EWRporta_ControllerPublic_Portal' AND {$controllerName} != 'XenForo_ControllerPublic_Login'">
Ad Code
</xen:if>
 

Jake Bunce

XenForo moderator
Staff member
#10
Also, here is some shorthand which is more easily expanded upon:

Code:
<xen:if is="!in_array({$controllerName}, array('EWRporta_ControllerPublic_Portal', 'XenForo_ControllerPublic_Login'))">
Ad Code
</xen:if>
 
B

bogus

Guest
#11
Thanks Jake, i was playing around and ended up with a Layer Ad i want to popup here http://www.brainlag.eu/pages/bnc_rules/
Its a Page and in ACP Edit i do have that URL http://www.brainlag.eu/admin.php?nodes/brainlag-bnc-rules.190/


I have now tried that
<xen:if is="{$contentTemplate} == 'bnx_rules'"><script type="text/javascript" src="http://view.binlayer.com/ad-55***.js">
<xen:else />
Google Adsense
</xen:if>
cause url portion is bnc_rules, i also tried
<xen:if is="{$contentTemplate} == 'brainlag-bnc-rules'"><script type="text/javascript" src="http://view.binlayer.com/ad-55***.js">
</script><xen:else />
Google Adsense
</xen:if>
because the 1. Example did not worked. After both did not do it, i´ve tried to play with the node number

<xen:if is="{$threadId} == x">

<xen:if is="{$threadId} == 190">
<script type="text/javascript" src="http://view.binlayer.com/ad-55***.js"></script>
<xen:else />

Google Adsense
</xen:if>
But all of them wont do it, maybe anyone can help me one more time? Thanks!

 

Jake Bunce

XenForo moderator
Staff member
#12
You can't use the contentTemplate to uniquely identify a page node.

Threadid checking also doesn't work in the container because the thread record isn't available there. But you can do it in the thread_view template:

Code:
<xen:if is="{$thread.thread_id} == 1">
	test
</xen:if>
 
B

bogus

Guest
#15
So, with the help of a friend its working now this way

<xen:if is="{$requestPaths.requestUri} == '/pages/bnc_rules/'">