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

Different Ads in Different Forums (Nodes)

Discussion in 'XenForo Questions and Support' started by lazer, May 31, 2012.

  1. lazer

    lazer Well-Known Member

    Hey all

    Is there a way to place a banner or ad in a particular forum (thread_view) with a conditional?

    Simply put:

    I would like to have banner "A" in forum 1,2,3 & 5
    I would like to have banner "B" in forum 4

    So, some kind of "if" statement? I'm not really keen on installing an add-on to achieve this, if it can be avoided...

    Cheers.
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    <xen:if is="in_array({$forum.node_id}, array(1, 2, 3, 5))">
    Banner A
    <xen:elseif is="{$forum.node_id} == 4">
    Banner B
    </xen:if>

    I think that's it.
     
    Jake Bunce likes this.
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Missing a slash:

    Code:
    <xen:if is="in_array({$forum.node_id}, array(1, 2, 3, 5))">
    Banner A
    <xen:elseif is="{$forum.node_id} == 4" />
    Banner B
    </xen:if>
    
     
    lazer and Yorick like this.
  4. lazer

    lazer Well-Known Member

    Great stuff, thank you! I take it that I can combine this with other "if" statements, such as guests only...?
     
    Yorick likes this.
  5. Chris D

    Chris D XenForo Developer Staff Member

    Absolutely.

    Code:
    <xen:if is="in_array({$forum.node_id}, array(1, 2, 3, 5))">
    Banner A
    <xen:elseif is="{$forum.node_id} == 4 AND !{$visitor.user_id}" />
    Banner B
    </xen:if>
    That's just an example where if you're in forum ID 4 AND a guest then you will see banner B.

    Lots of other combinations too. I'm sure you'll work it out :) But let us know if you need anything else.
     
    lazer likes this.
  6. lazer

    lazer Well-Known Member

    Very nice, thank you :D
     
    Yorick likes this.
  7. craigiri

    craigiri Well-Known Member

    FYI, I am doing the above by calling an outside ad banner program - with a variable that depicts the node.

    This is useful if you have rotating ads in each forum as opposed to just a fixed banner.
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

Share This Page