PDA

View Full Version : Show Ads After post number "x" and "x"


mcyates
19 Nov 2005, 14:28
This is a very simple template modification have similar to adsence hack and the random postbit advert hack. But you have more control with this hack as you change the option for where the adverts will appear "after which message"

Add This code to the bottom of your postbit template.

Here is the code:


<if condition="$post[postcount]==1">
<p align="center">

[AD CODE GOES HERE]

</p>
</if>


The above code would show an ad after the first post on every thread. Change this number to show the advert under a different post. Or use loads together like this:


<if condition="$post[postcount]==1">
<p align="center">

[AD CODE GOES HERE]

</p>
</if>

<if condition="$post[postcount]==10">
<p align="center">

[AD CODE GOES HERE]

</p>
</if>

<if condition="$post[postcount]==20">
<p align="center">

[AD CODE GOES HERE]

</p>
</if>


The above will show adverts after the 1st, 10th and 20th post in every thread.

Also there is another way for doing this:


<if condition="in_array($post['postcount'], array(1, 5, 10, 15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100))">
<if condition="in_array($bbuserinfo['usergroupid'], array(1, 2, 3, 4,5,6,7,8, 9))">
$spacer_open
<div style="padding:0px 0px $stylevar[cellpadding]px 0px">

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="thead" align="left">Sponsored Links (<a href=/payments.php>No Ads</a>)</td>
</tr>
<tr>
<td class="alt1" align="center">

[AD CODE GOES HERE]

</td>
</tr>
</table>

</div>
$spacer_close

</if></if>

Slapyo
19 Nov 2005, 16:08
You could combine them all into one.

<if condition="$post[postcount]==1 OR $post[postcount]==10 OR $post[postcount]==20">
<p align="center">

[AD CODE GOES HERE]

</p>
</if>

mcyates
19 Nov 2005, 18:13
yeah, thanks for that. But i've got different codes for each one. that would be fine for 1 standard adverts of the same.

Tony G
20 Nov 2005, 00:36
Thanks for sharing. Could you please put your instructions in a .txt file and attach it also? Thanks.

Snake
21 Nov 2005, 12:28
Thanks man.

manguish
26 Nov 2005, 19:54
This works better for me :


<if condition="$post[postcount] == 1">
<if condition="in_array($bbuserinfo['usergroupid'], array(1, 2, 3, 4, 8, 9, 10, 22, 6))">
$spacer_open
<div style="padding:0px 0px $stylevar[cellpadding]px 0px">

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="thead" align="left">Sponsored Links</td>
</tr>
<tr>
<td class="alt1" align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-8986773341913936";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "8B1306";
google_color_bg = "132C4B";
google_color_link = "FFFFFF";
google_color_url = "FFFF00";
google_color_text = "FFFFFF";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>
</tr>
</table>

</div>
$spacer_close

</if></if>

wolfstream
13 Dec 2005, 01:15
Yet another way to do this:

<if condition="in_array($post['postcount'], array(1, 5, 10, 15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100))">
<if condition="in_array($bbuserinfo['usergroupid'], array(1, 2, 3, 4,5,6,7,8, 9))">
$spacer_open
<div style="padding:0px 0px $stylevar[cellpadding]px 0px">

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="thead" align="left">Sponsored Links (<a href=/payments.php>No Ads</a>)</td>
</tr>
<tr>
<td class="alt1" align="center">
<script type="text/javascript"><!--
google_ad_client = "your google Stuff Here!";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "89959B";
google_color_bg = "BEC8CE";
google_color_link = "000000";
google_color_url = "00008B";
google_color_text = "496690";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>
</tr>
</table>

</div>
$spacer_close

</if></if>

This will do as above, placing an ad every 5 posts (up to 100). To exclude groups or raise the post limits, just change the first two arrays :)

Enjoy

Lapsetur
25 Dec 2005, 10:52
It did not work in postbit template so put it into postbit_legacy and works fine

Lapsetur
29 Dec 2005, 11:57
Yet another way to do this:

<if condition="in_array($post['postcount'], array(1, 5, 10, 15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100))">
<if condition="in_array($bbuserinfo['usergroupid'], array(1, 2, 3, 4,5,6,7,8, 9))">
$spacer_open
<div style="padding:0px 0px $stylevar[cellpadding]px 0px">

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="thead" align="left">Sponsored Links (<a href=/payments.php>No Ads</a>)</td>
</tr>
<tr>
<td class="alt1" align="center">
<script type="text/javascript"><!--
google_ad_client = "your google Stuff Here!";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "89959B";
google_color_bg = "BEC8CE";
google_color_link = "000000";
google_color_url = "00008B";
google_color_text = "496690";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>
</tr>
</table>

</div>
$spacer_close

</if></if>

This will do as above, placing an ad every 5 posts (up to 100). To exclude groups or raise the post limits, just change the first two arrays :)

Enjoy


I installed also this but adsense does not show

wolfstream
29 Dec 2005, 12:51
works fine here, make sure you're in one of the usergroups that actually shows this, and it should work fine.
Also, make sure that you replace all the google stuff with your own google code and settings, that could be part of it as well.

I've been running like this for a while, had no problems with it at all :)

ahmed-samara
29 Dec 2005, 13:28
Thanks man.

Lapsetur
29 Dec 2005, 14:17
Sometimes it shows sometimes not I couldn't figure out

wolfstream
29 Dec 2005, 14:44
Sometimes it shows sometimes not I couldn't figure out
If it's "randomly" not working, then most likely it's not the code at all, but communication with adsense. This happens occasionally.

Lapsetur
29 Dec 2005, 14:47
Well the code did not work with postbit but work on postbit_legacy. Why this happens also?

Lapsetur
29 Dec 2005, 14:50
I also put an adsense code to header and it work fine but in ipostbit_legacy I am having problem

nishv
13 Oct 2006, 01:45
Rather than doing that, how about adding a code to show every X post...

The Following will work with vB 3.6.1

<if condition="$post[postcount] % X == 0">

Replace X with the Number.

Camz
15 Jan 2007, 18:59
Can i use this hack on posbit?

mcyates
03 Feb 2007, 09:13
yes, just put it at the bottom of that template and it will work in exactly the same way.

mcyates
18 Jun 2007, 11:42
Well the code did not work with postbit but work on postbit_legacy. Why this happens also?

It should work properly. Sometimes if you have google adverts above this code then google stop showing them. Google only allow so many ads on the page, 2 or 3 I think.