• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.1 Display Advertisement In First Post; Right Aligned Like in vB

TheBigK

Well-known member
#1
I'm aware of existing advertisement locations in XenForo. But can't seem to find a way to display a 300x250 rectangle on the right side of the content in first post. Does anyone know how to do that? :)
 

TheBigK

Well-known member
#3
Use the ad_message_body template and float the content right.

Use a conditional to restrict it to the first post: http://xenforo.com/community/threads/frequently-asked-questions.5183/#post-182355

Like this:
Code:
<xen:hook name="ad_message_body" />
<xen:if is="{$post.position} == 0 AND !{$message.conversation_id}">
<div style="float: right">
Ad content here
</div>
</xen:if>
Brogan: You are Awesome!

I'll go ahead and ask for more -

  1. The text runs into the ads. How do I add 5 pixel margin around the ad spot?
  2. If the text in first post is just 1 line; then the ad-spot occupies the signature area as well. Is there a way to fix this? :)
 

Brogan

XenForo moderator
Staff member
#4
<div style="float: right; padding-left: 5px">

Oh I missed the second point. Use this code instead:
Code:
<xen:hook name="ad_message_body" />
<xen:if is="{$post.position} == 0 AND !{$message.conversation_id}">
<div style="min-height: 250px">
<div style="float: right; padding-left: 5px">
Ad content here
</div>
</div>
</xen:if>
 

TheBigK

Well-known member
#5
<div style="float: right; padding-left: 5px">

Oh I missed the second point. Use this code instead:
Code:
<xen:hook name="ad_message_body" />
<xen:if is="{$post.position} == 0 AND !{$message.conversation_id}">
<div style="min-height: 250px">
<div style="float: right; padding-left: 5px">
Ad content here
</div>
</div>
</xen:if>
Hi Brogan. This works well. Just a little problem. If the post has attachment, then the attachment section in post runs into the ad-spot. Is it possible to limit the size of attachment section so that it does not mess with the advertisement?
 

TheBigK

Well-known member
#6
Hi Brogan. This works well. Just a little problem. If the post has attachment, then the attachment section in post runs into the ad-spot. Is it possible to limit the size of attachment section so that it does not mess with the advertisement?
Quoting myself. Can someone suggest a CSS fix for this issue?

The code above beautifully shows advertisement in the first post as expected. However, if the first post has an attachment or say a quote, then the quote runs into the advertisement. Is there a way to automatically adjust the width of quote when an advertisement is displayed?
 

TheBigK

Well-known member
#7
Just a question: The above hack shows post only after first post in the thread. I'd ideally like to show the advertisement in every top post on all the pages in thread. What condition should I use?
 

TheBigK

Well-known member
#9
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND !{$message.conversation_id}">
You are - A-W-E-S-O-M-E-S-T! :D

May I request the CSS trick to prevent the 'quotes' and 'attachments area' running into advertisements in first post? :unsure:
 

jauburn

Well-known member
#10
<div style="float: right; padding-left: 5px">

Oh I missed the second point. Use this code instead:
Code:
<xen:hook name="ad_message_body" />
<xen:if is="{$post.position} == 0 AND !{$message.conversation_id}">
<div style="min-height: 250px">
<div style="float: right; padding-left: 5px">
Ad content here
</div>
</div>
</xen:if>

How do you get this code to fall at the bottom of the first post rather than the top? That is, after the post text, not before, and to the left, not right? Thanks.