I've taken a look at the Conditional Statements but couldn't find one that tells how to add an Ad after the first unread message.
Could anyone please tell me how to do that?
If you use three separate ones, you can track how they're performing.
How can I show different content to guests and logged in members?
<xen:if is="{$visitor.user_id}">
This content will show to logged in members
<xen:else />
This content will show to guests
</xen:if>
<xen:hook name="ad_below_top_breadcrumb" />
<xen:if is="{$contentTemplate} == 'thread_view' OR {$contentTemplate} == 'forum_view'">
<div class="adsense">
<style>
.top-responsive { width: 320px; height: 50px; }
@media(min-width: 500px) { .top-responsive { width: 468px; height: 60px; } }
@media(min-width: 800px) { .top-responsive { width: 728px; height: 90px; } }
</style>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Top Responsive -->
<ins class="adsbygoogle top-responsive"
style="display:inline-block"
data-ad-client="ca-pub-1234"
data-ad-slot="8948558153"
data-ad-format="horizontal"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</xen:if>
<xen:hook name="ad_message_body" />
<style type="text/css">
.message-body-dynamic {
width: 125px;
height: 125px;
}
@media(min-width: 360px) {
.message-body-dynamic {
width: 180px;
height: 150px;
}
}
@media(min-width: 640px) {
.message-body-dynamic {
width: 300px;
height: 250px;
}
}
</style>
<xen:if is="!{$visitor.user_id}">
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0">
<xen:if is="@enableResponsive">
<div style="min-height: 125px; margin-left: 8px; float: right">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Message Body - Dynamic -->
<ins class="adsbygoogle message-body-dynamic"
style="display:inline-block"
data-ad-client="ca-pub-1234567890"
data-ad-slot="123456"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
<xen:else />
<div style="min-height: 125px; margin-left: 8px; float: right">
<script type="text/javascript">
google_ad_client = "ca-pub-1234567890";
/* Message Body */
google_ad_slot = "654321";
google_ad_width = 300;
google_ad_height = 250;
</script>
<script type="text/javascript"
src="//pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</xen:if>
</xen:if>
</xen:if>
What follows below are examples using standard AdSense code.
Google have very recently introduced asynchronous AdSense code - see here for how to implement that: http://xenforo.com/community/resources/responsive-adsense.2084/update?update=5334
<xen:if is="!{$visitor.user_id}">
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0">
<xen:if is="@enableResponsive">
<div style="min-height: 125px; margin-left: 8px; float: right">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Message Body - Dynamic -->
<ins class="adsbygoogle message-body-dynamic"
style="display:inline-block"
data-ad-client="ca-pub-1234567890"
data-ad-slot="123456"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
<xen:else />
<div style="min-height: 125px; margin-left: 8px; float: right">
<script type="text/javascript">
google_ad_client = "ca-pub-1234567890";
/* Message Body */
google_ad_slot = "654321";
google_ad_width = 300;
google_ad_height = 250;
</script>
<script type="text/javascript"
src="//pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</xen:if>
</xen:if>
</xen:if>
We use essential cookies to make this site work, and optional cookies to enhance your experience.