XF 2.0 Template Conditional for Thread ID

MickkD

Member
Hello All,

I am looking for a template conditional to allow me to stop Adsense being shown on specific threads.

I tried this in the adverts section.

Code:
<xf:if is="!in_array($threadId, [43100,44517,38327,39024,45687])">
ADSENSE CODE
</xf:if>

Does anyone know the conditional for an array of thread id's

Thank you very much.

Mick
 
Yea, there is a field "HTML", you can use XF template syntax there. I'm assuming you're showing your ad within a post, so that should work. Otherwise, please post your ad config.
 
Code:
<xf:if is="!in_array($post.thread_id, [43100,44517,38327,39024,45687])">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Xen Footer -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-*************"
     data-ad-slot="4534646553"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
    TEST
</xf:if>

This is the code I am using, I put in the TEST after the google code just to be sure that I don't see it on the threads that correspond to the array...

But its still showing the TEST and the advert, I also tried $thread

Thank you.

Mick
 
There is no position "footer" for me. Are you using some kind of addon which adds additional positions? Otherwise, please just screenshot the Position: line. Or try this one:
HTML:
<xf:if is="{$__globals.controller} !== 'XF:Thread' OR !in_array({$__globals.contentKey}, ['thread-43100', 'thread-44517', 'thread-38327', 'thread-39024', 'thread-45687']
)">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Xen Footer -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-*************"
     data-ad-slot="4534646553"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</xf:if>
 
It was this area:

Code:
Container breadcrumb (bottom): Above
Inside the page container, directly above the bottom breadcrumb on every page.

And thank you very much!!!

The condition worked a treat, now I can action any URLS that Adsense have an issue with and block them...

Mick
 
Last edited:
I'm looking to pass the thread ID back to Ad Manager so we can control ad line items and orders from GAM use targeting.

How do I simply obtain the thread ID so I can put it in the ad tag in the advertising system like so:

setTargeting('forum-thread', ['{$threadId}']).

How do I call the thread ID from Page_container?

Is it something like this?
$__globals.contentKey.xxxxxxx
 
Back
Top Bottom