XF 2.2 How to block ads in specific forums

sky55

New member
welcome everybody
I moved from vb4 to xenforo 2.2
and I used the code to display ads in specific forums in vb4
<vb:if condition="!in_array($GLOBALS[forumid], array(56,57,58))">ads code</vb:if>
But I don't know what code is appropriate for that in xenforo and where to add it specifically to display all the pages
Kindest regards
 
Solution
There is a built in ad template system in XF.

You can use conditional statements such as this:

HTML:
<xf:if is="{$__globals.forum.node_id} == 2">
    Display ad for node ID 2
</xf:if>

<xf:if is="in_array({$__globals.forum.node_id}, [2,3,4])">
    Display ad for node IDs 2, 3, 4
</xf:if>

<xf:if is="{$__globals.forum.node_id} != 2">
    Don't display ad for node ID 2
</xf:if>

<xf:if is="!in_array({$__globals.forum.node_id}, [2,3,4])">
    Don't display ads for node IDs 2, 3, 4
</xf:if>

1602538908747.png

The conditional statement will vary depending on the template you are using to display the ad, and which pages you want to display it on.

Brogan

XenForo moderator
Staff member
There is a built in ad template system in XF.

You can use conditional statements such as this:

HTML:
<xf:if is="{$__globals.forum.node_id} == 2">
    Display ad for node ID 2
</xf:if>

<xf:if is="in_array({$__globals.forum.node_id}, [2,3,4])">
    Display ad for node IDs 2, 3, 4
</xf:if>

<xf:if is="{$__globals.forum.node_id} != 2">
    Don't display ad for node ID 2
</xf:if>

<xf:if is="!in_array({$__globals.forum.node_id}, [2,3,4])">
    Don't display ads for node IDs 2, 3, 4
</xf:if>

1602538908747.png

The conditional statement will vary depending on the template you are using to display the ad, and which pages you want to display it on.
 
Solution

sky55

New member
There is a built in ad template system in XF.

You can use conditional statements such as this:

HTML:
<xf:if is="{$__globals.forum.node_id}==2">
    Display ad for node ID 2
</xf:if>

<xf:if is="in_array({$__globals.forum.node_id}, [2,3,4])">
    Display ad for node IDs 2, 3, 4
</xf:if>

<xf:if is="!{$__globals.forum.node_id}==2">
    Don't display ad for node ID 2
</xf:if>

<xf:if is="!in_array({$__globals.forum.node_id}, [2,3,4])">
    Don't display ads for node IDs 2, 3, 4
</xf:if>

View attachment 237405

The conditional statement will vary depending on the template you are using to display the ad, and which pages you want to display it on.
Thank You So Much Dear
Everything is fine now
Kindest regards
 
Top