MyBB Community Forums

Full Version: add google adsense in first post
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
How we can add google adsense only to 1st post of thread ? through code or any plugin available ?
thanks
(2014-12-05, 07:00 PM)[email protected] Wrote: [ -> ]How we can add google adsense only to 1st post of thread ? through code or any plugin available ?
thanks
dear all, still waiting for any help, suggestions 
Download Template Conditionals: http://mybbhacks.zingaburga.com/showthread.php?tid=464 and activate it.

Then add this code to postbit/postbit_classic templates:
<if $postcounter == 1 then>
...ad HTML here...
</if>
thanks it worked.
how we can align right within the first post ?
how we can align right within the first post ?
You have to add the adsense div container right above {$post['message']} and also add some inline style into that adsense div.

eg:
..........<snip>
<div class="post_body scaleimages" id="pid_{$post['pid']}">
	<if $postcounter == 1 then>
		<div style="display: inline-block;float: right;padding-left: 10px;">   
		<!--...YOUR ADSENSE SCRIPT...-->
		</div>
	</if>
	{$post['message']}
</div>
<br class="clear" />
<snip>...........
After following your provided code, google ad is coming on right but 

my all replies of posts are not showing ??
It works for me but you could try it without <br class="clear" />.

<div class="post_body scaleimages" id="pid_{$post['pid']}">
    <if $postcounter == 1 then>
        <div style="display: inline-block;float: right;padding-left: 10px;">   
        <!--...YOUR ADSENSE SCRIPT...-->
        </div>
    </if>
    {$post['message']}
</div>

[attachment=33328]
tried condtion above but problem is ad is behind the text.  Sad
The problem is a css styling of your add script.

Try a change in theme global.css from:
.separator {
margin: 5px;
padding: 0;
height: 0px;
font-size: 1px;
list-style-type: none;
}

to:
.separator {
margin: 5px;
padding: 0;
height: auto;
font-size: 1px;
list-style-type: none;
}
Pages: 1 2