Thanks for the information but didn't work the way I wanted.Number the posts from "0" on the page (thread starter) so post "5" would be "4". like this:
Code:<xf:if is="$post.position % $xf.options.messagesPerPage == 0"> <div style="text-align:center;"> {your code} </div> </xf:if> For after 8th post: <xf:if is="$post.position % $xf.options.messagesPerPage == 7"> For after 18th post: <xf:if is="$post.position % $xf.options.messagesPerPage == 17">
I am trying to prevent adsense from showing in one thread
$thread
, you should be able to use this code:<xf:if is="$thread && $thread.thread_id != 123">
Show content..
</xf:if>
123
is your thread id.If you have access to$thread
, you should be able to use this code:
Code:<xf:if is="$thread && $thread.thread_id != 123"> Show content.. </xf:if>
123
is your thread id.
Try the following condition in the advertisement HTML code:I am trying to hide the ad in only one thread. How would I combine that with this:
<xf:if is="$xf.reply.template == 'thread_view'">
<xf:if is="$xf.reply.contentKey != 'thread-123'">
Your ad code here.
</xf:if>
{{dump($xf)}}
is your friend.Try following in the advertisement HTML code:
$template
and $thread
?<xf:if is="$xf.reply.template == 'thread_view'">
with <xf:if is="$xf.reply.contentKey != 'thread-123'">
(123 == thread_id), like suggested by @smozgur.Oh, I didn't mean something badWas not trying to be ungrateful!
dump
function so much, so I always mention that in template variable questions.$xf.reply
, as you also figured out.$xf.reply.contentKey
contains a "thread-XXX" string if a thread is displayed, otherwise null
. If you just use the condition I posted to wrap your ad code, by providing the thread ID in place of XXX, then it should work without problems to hide the ad only for that thread... or in your case I assume you want:I guess you should replace<xf:if is="$xf.reply.template == 'thread_view'">
with<xf:if is="$xf.reply.contentKey != 'thread-123'">
<xf:if is="$xf.reply.template == 'thread_view' && $xf.reply.contentKey != 'thread-123'">
.@xf.reply.template
since contentKey
should work fine. Like this (replace XXX with that particular thread ID)<xf:if is="$xf.reply.contentKey != 'thread-XXX'">
<div class="advertising-wide">
<div style="margin-top:0px;margin-bottom:8px;">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- fixed 728x90 -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-XXXXX"
data-ad-slot="XXXXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
<div class="advertising-narrow">
<div style="margin-top:0px;margin-bottom:8px;">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- fixed 320x100 -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:50px"
data-ad-client="ca-pub-XXXXXXX"
data-ad-slot="XXXXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
</xf:if>
Note: If you are using the page-level cache, then you'll need to wait until the page cache is flushed. I mention this because it took me some time, in the beginning, to realize why my guest template changes were not working.So I can just add your line?
do you haveI don't know what kind of cache-ing I am using
$config['pageCache']['enabled'] = true;
in your config.php?<xf:if is="$xf.reply.template == 'thread_view' && $xf.reply.contentKey != 'thread-123'">
<xf:if is="in_array($xf.reply.template, ['forum_list', 'forum_view', 'thread_view', 'thread_view_type_poll', 'whats_new', 'whats_new_posts'])">
<xf:if is="in_array($xf.reply.template, ['forum_list', 'forum_view', 'thread_view', 'thread_view_type_poll', 'whats_new', 'whats_new_posts']) && $xf.reply.contentKey != 'thread-123'">
. && $xf.reply.contentKey != 'thread-123'
.The final place I need to prohibit ads is in my "Ad Below Post" in an add-on by Andy. Code is here:
<xf:if is="$xf.reply.template == 'thread_view' && $xf.reply.contentKey != 'thread-123'">
// Your existing Code
</xf:if>
<xf:if is="$template == 'thread_view' && $thread && $thread.thread_id != 123">
Show content..
</xf:if>
This works!<xf:if is="in_array($xf.reply.template, ['forum_list', 'forum_view', 'thread_view', 'thread_view_type_poll', 'whats_new', 'whats_new_posts']) && $xf.reply.contentKey != 'thread-123'">
.
<xf:if is="in_array($xf.reply.template, ['forum_list', 'forum_view', 'thread_view', 'thread_view_type_poll', 'whats_new', 'whats_new_posts']) && $xf.reply.contentKey != 'thread-123' && $xf.reply.contentKey != 'node-456'">
.
If I entered this ^^ correctly, it blocks all ads not just the one intended.<xf:if is="$template == 'thread_view' && $thread && $thread.thread_id != 123"> Show content.. </xf:if>
We use essential cookies to make this site work, and optional cookies to enhance your experience.