1. 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

Discussion in 'XenForo Questions and Support' started by bogus, Aug 17, 2012.

  1. bogus

    bogus Guest

    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
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    bogus and Jake Bunce like this.
  3. bogus

    bogus Guest

    Thanks a lot. I will try that
     
  4. bogus

    bogus Guest

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

    I use "Set as Index Controller"
     
  5. Chris D

    Chris D XenForo Developer Staff Member

    <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
     
  6. bogus

    bogus Guest

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

    Chris D XenForo Developer Staff Member

    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 :)
     
    bogus likes this.
  8. bogus

    bogus Guest

    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
     
  9. Chris D

    Chris D XenForo Developer Staff Member

    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>
     
    bogus and Jake Bunce like this.
  10. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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> 
    
     
    bogus and Chris D like this.
  11. bogus

    bogus Guest

    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
    cause url portion is bnc_rules, i also tried
    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">

    But all of them wont do it, maybe anyone can help me one more time? Thanks!

     
  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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>
    
     
  13. bogus

    bogus Guest

  14. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  15. bogus

    bogus Guest

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

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

Share This Page