XF 1.5 Adsense in the first post within the content

Neutral Singh

Well-known member
How can I show adsense within first and/or last post of every page like this: The message should seamlessly adjust along the sides of the adsense block...

adsense left.webpadsense right.webp
 
Last edited:
Hi @Neutral Singh

As a starting point..

Place it in ad_message_body template:
https://xenforo.com/community/resources/visual-list-of-ad-locations.1383/

Then wrap using a template conditional:
https://xenforo.com/community/resources/conditional-statements.1604/

First post:
Code:
<xen:if is="{$post.position} == 0 AND !{$message.conversation_id}">
code
</xen:if>

or Last post:
Code:
<xen:if is="{$post.position} == {$thread.reply_count}">
code
</xen:if>

You'll probably need to use CSS to float the ad to the right too. Maybe others can help too - have not placed an ad in that position before.
 
Thank you!

To show adsense block on every page, i used the following code:

Code:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND !{$message.conversation_id}">
Can't figure out how to show adsense on the last post of every page.

So, i have reached this stage:

adsense now 1.webp

Now, how can i twist the CSS to show the block as desired in my first post.

adsense right.webp

Thank you
 
Back
Top Bottom