XF 2.2 Restricting advertising from custom page node

cwe

Well-known member
I created an HTML based page node. The ACP shows "_page_node.38" under the Template HTML for the node. What do I need to put in the "Prevent ads showing in these templates:" block on the Setup > Advertising page so that ads won't show on that page node?
 
Solution
Wrap your ad code in this and it should work:

Code:
<xf:if is="$__globals.containerKey !== 'node-38'">
Ad code here
</xf:if>
Wrap your ad code in this and it should work:

Code:
<xf:if is="$__globals.containerKey !== 'node-38'">
Ad code here
</xf:if>
 
  • Like
Reactions: cwe
Solution
Thanks, but I was hoping to use XF built in system for this. So no one knows what, if anything, needs to be prepended to _page_node.38 to complete the template name for the "Prevent ads showing in these templates:" block on the Setup > Advertising page?
 
Thanks, but I was hoping to use XF built in system for this. So no one knows what, if anything, needs to be prepended to _page_node.38 to complete the template name for the "Prevent ads showing in these templates:" block on the Setup > Advertising page?

If you look at the _ads template, all that the "prevent ads showing in these templates" list is doing is simply wrapping all the ad code in a conditional. It's using $xf.reply.template as the conditional check for each template you list. If you dump variables for a page node, you'll see this:

1702681917662.webp

XF uses the "reply -> template" name. That is the same across all page templates, so you need to use a conditional like mine above using containerKey/contentKey to target specific pages.
 
That is the template name.

Well, I just added _page_node.38 to the list in the "Prevent ads showing in these templates:" block on the Setup > Advertising page and then checked the page and ads still showed. Does this (the "Prevent ads showing in these templates:" block on the Setup > Advertising page) only prevent ads from showing within the html widget for the page as opposed to the page node itself?
 
Top Bottom