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

Wordwrap for ad code in ad_message_body?

#1
Hello everyone, looking for some advice on how to get text/quotes/pics to word wrap to the left, or align properly with displaying a google adsense (or any) ad in the first and last post of every thread. So far I have it showing correctly where I want it to, but I have had no luck with a variety of div usages and floats. Either a quote in a post gets put on top of it or the text of the post gets placed beneath.

I referenced this good thread (Adding Advertisements with templates), and searched to no avail finding if someone had an example of a proper usage of the css or div to have good formatting of the ad within the post.

Here is my code, need help with the formatting to get the ad to display:
- Within the post
- Right side of the post window
- Allow the traditional user post to wrap around the box on the left side and beneath

Code:
<xen:if is="!{$message.conversation_id}">
    <xen:if is="!{xen:helper ismemberof, $visitor, 19}">
        <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0">

            <div style=”display:block;margin: 5px 5px 5px 5px;”>

                AD CODE FIRST POST AD

            </div>

        <xen:else />
        <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == {$xenOptions.messagesPerPage} - 1 OR {$post.position} == {$totalPosts} - 1">

            <div style=”display:block;margin: 5px 5px 5px 5px;”>

                AD CODE LAST POST AD

            </div>
        </xen:if>
        </xen:if>
    </xen:if>
</xen:if>
I don't need any troubleshooting with the conditionals (unless there is a better way to clean it up!), but mention what works for me since it may help someone else. I found all of these thanks to others that posted them across different threads here, and just combined them to get what I wanted/desired. The conditionals that are working successfully (for me at least), are to:

- Not display to anyone in usergroup 19 (contributors)
Code:
<xen:if is="!{xen:helper ismemberof, $visitor, 19}">
- Show on first post
Code:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0">
- Show on last post OR Show on last post of only 1 page
Code:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == {$xenOptions.messagesPerPage} - 1 OR {$post.position} == {$totalPosts} - 1">
- Do not show in conversations
Code:
<xen:if is="!{$message.conversation_id}">
Attached are two example pics of what it is generating with the ads, and arrows pointing where I want the ad to be.

Adformat.png Adformat2.png

I imagine that this is probably very trivial to some of you, but it has been eluding me on how to properly format. Thanks in advance for anyone that can help me out.

John
 
#3
Have you tried using float:right ?
I tried that earlier today (maybe incorrectly!) When it floated right, if someone had a quote in their post, the ad would go right on top.

Here is what I used on that try:

Code:
<div style=”display:block;float:right;margin: 5px 5px 5px 5px;”>
Here is what it looks like:

Adformat3.png

Ok... sigh... I am an idiot. It looks like it is working perfectly, the quote is just so close to the ad, I "thought" it was disappearing under the ad. Sigh. To get rid of that affect, should I just bump the px out more on the left side?
 

Brogan

XenForo moderator
Staff member
#4
That's simply because there's not enough width for the advert and the quote box.

You would either need to increased the width of the message body, or reduce the width of the quote box.
You could try using a percentage for the quote box width, something like 85% might work.
 
#5
You could try using a percentage for the quote box width, something like 85% might work.
Use the MISC width, or the BB CODE BLOCK border width? Seems like I can't find which one to change. None of those templates I have are modified under Style Properties: BB Code Elements.
 

Brogan

XenForo moderator
Staff member
#6
The margin right is set in Style Properties -> BB Code Elements -> BB Code Block: Margin Right
The default setting is: @messageInfo.margin-left

You can set that to 0 and in the Miscellaneous Width box enter 85%

I'm not sure if it will fix your problem or not, but it's worth a try.
 

Claudio

Well-known member
#8
Thanks, worked like a champ!
I´m using this for the first adsense block
Code:
<div style=”display:block;float:left;margin: 5px 5px 5px 5px;”>
but it´s not like this one (but at the left)
Adformat3.png
No matter where I float it (left or right) I see the ad exactly like this:
ad1.png

I don´t know why...it should be like the last adsense block at the last thread...

Any suggestion?
 

Claudio

Well-known member
#9
The margin right is set in Style Properties -> BB Code Elements -> BB Code Block: Margin Right
The default setting is: @messageInfo.margin-left

You can set that to 0 and in the Miscellaneous Width box enter 85%

I'm not sure if it will fix your problem or not, but it's worth a try.
Hi Brogan, can you help me with the 1st add? (see post above)
 
#10
I know it is a very old post, but it works good :)

How can I change this code and make this ad only visible for non members

Code:
<xen:hook name="ad_message_body" />
<xen:if is="!{$message.conversation_id}">
    <xen:if is="!{xen:helper ismemberof, $visitor, 19}">
        <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0">

            <div style="min-height: 250px; margin-left: 10px; margin-right: 10px; float: left">

            HERE AD CODE

            </div>

        <xen:else />
        <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == {$xenOptions.messagesPerPage} - 1 OR {$post.position} == {$totalPosts} - 1">

            <div style="min-height: 250px; margin-left: 30px; float: left">

                AD CODE LAST POST AD

            </div>
        </xen:if>
        </xen:if>
    </xen:if>
</xen:if>