Ad after first post - which template?

Diablotic

Active member
Which template should I use to insert my code that would display ad after first message (outside first message) in the way it looks like it is another post.
I have my code ready but I cannot figure into which template I should insert it to.
 

principia

Well-known member
or you can use the "rotating ads" addon. theres an option for the second post and you need no template edits
 

Diablotic

Active member
@Brogan: That was the first conditional I used and it didn't work that's why I started this thread.
Using this conditional it displays advert in the first post but I do want it to show outside it, just as it is another, standalone post.

@principia: I do not want to use any addons to do that.
 

Brogan

XenForo moderator
Staff member
It doesn't display it in the post, the ad_message_body template does that.

If you want to create more separation however, add this as the first line in the ad template

</li><li>
 

Diablotic

Active member
Yes, had tried that before but also with no luck.

First picture is for the option without </li><li>
Second one is what happens after I use </li><li>

withoutli.jpg
withli.jpg

As you can see adding the code into ad_message_body is adding "advert" into first post. I do not want that. I want to have "advert" between first and second post.

Using XF 1.0, no changes to the default theme.
 

Brogan

XenForo moderator
Staff member
There must be something wrong with your code, it works fine for me in my testing.
 

Diablotic

Active member
When you open ad_message_body, do you have any code in there?
In mine there is:
Code:
<xen:hook name="ad_message_body" />
.
 

Brogan

XenForo moderator
Staff member
That's just text explaining which hook is used.

You can remove that and place whatever code you want in that template.

As I said though, you need to use the ad_message_below template, not the ad_message_body template.
 

planetzu

Member
Hey guys, what will I need to edit in the conditional if I want to display this Ad only to non-registered users?

<xen:if is="{$post.position} == 0">
advert
</xen:if>
 

Jens1986

Active member
It doesn't display it in the post, the ad_message_body template does that.

If you want to create more separation however, add this as the first line in the ad template

</li><li>
Why does this code not work?

ad_message_below:
Code:
<xen:comment> PLACE YOUR ADVERTISEMENT CODE DIRECTLY BELOW </xen:comment>
</li><li><xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND {$thread.reply_count} > 0">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- ALOPECI TOPP -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-...."
     data-ad-slot="...."
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</xen:if>
It breaks the design, the posts after post #2 goes to 100% width
 

AtemusVdq

Member
Also having issues with <li class="">my adsense code</li> in ad_message_below (right after first post)

I've successfully added it at the end of all messages and above threads list but somehow adding it in ad_message_below it breaks the design leaving 2nd post showing as empty.
 

AtemusVdq

Member
I don't really see a reason to install an addon just for this.

Also adding a banner without any <li></li> has the exact same result that addon has, my issue starts while adding the <li> tags.
 

Webby

Member
ad_message_below

Use this conditional:

<xen:if is="{$post.position} == 0">
advert
</xen:if>
Bro it works with going under the first post, only problem is that it looks messed up for me. Any ideas on how this could be resolved or what the cause could be?

Thanks in advance.

Screen Shot 2016-02-03 at 8.09.57 PM.png

I added the code to the ad_message_body to avoid the above issue but now I need the ad to appear underneath the content of the 1st post.

This is what I have now:

Screen Shot 2016-02-03 at 8.16.03 PM.png

The reason why I need it under is because I have an ad in the ad_above_content template so it clutters the page as it is now.
 
Last edited:

Webby

Member
ad_message_below

Use this conditional:

<xen:if is="{$post.position} == 0">
advert
</xen:if>
Bro do you know how to make an ad appear after ever 3 posts? I know some java but not PHP. Its so simple to do but I can't. :X3:
 
Top