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

Discussion in 'XenForo Questions and Support' started by TheBigK, Jan 9, 2012.

  1. TheBigK

    TheBigK Well-Known Member

    I'm using following code to display adsense on specific pages -

    <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"?
  2. Syndol

    Syndol Guest

    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}">
    EQnoble likes this.
  3. TheBigK

    TheBigK Well-Known Member

    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

  4. Syndol

    Syndol Guest

    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.
  5. TheBigK

    TheBigK Well-Known Member

    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?
  6. Brogan

    Brogan XenForo Moderator Staff Member

    Jake Bunce, infis, Syndol and 2 others like this.
  7. TheBigK

    TheBigK Well-Known Member

    Thanks a lot, Brogan. I'll give it a try soon!

Share This Page