View Full Version : adsense in first post
jcodemasters
02-23-2007, 01:15 PM
Hello,
I am wondering, if anyone here can tell me how to add adsense code in first post at the bottom.. just like this http://www.talkgold.com/forum//r152221-.html
I just would like to know template name.. :)
it would be really good.. if i can add this after every second post too :D
CyberAlien
02-23-2007, 02:34 PM
Don't know if this will work, but...
open includes/class_postbit.php, find this: function construct_postbit(&$post)
{
add after it: static $post_counter;
if(!isset($post_counter))
{
$post_counter = 0;
}
else
{
$post_counter ++;
}
then in postbit use <if condition="$post_counter == 0"> ad code here </if>
jcodemasters
02-23-2007, 02:36 PM
Don't know if this will work, but...
open includes/class_postbit.php, find this: function construct_postbit(&$post)
{
add after it: static $post_counter;
if(!isset($post_counter))
{
$post_counter = 0;
}
else
{
$post_counter ++;
}
then in postbit use <if condition="$post_counter == 0"> ad code here </if>
thank you all try for this..
Digitalus
02-23-2007, 02:58 PM
You can add this in your postbit or postbit_legacy..
This is the easy way ;)
<if condition="$post[postcount] == 1">
<table class="tborder" cellpadding="6" cellspacing="0" border="0" width="100%" align="center">
<tr>
<td class="thead" align="left">-- Sponsored Links --</td>
</tr>
<tr>
<td class="alt1" align="center"> Here you ads code </td>
</tr>
</table>
</if>
CyberAlien
02-23-2007, 03:05 PM
Doh. If I only knew about $post['postcount'] variable... :)
jcodemasters
02-24-2007, 06:12 PM
thanks it works perfect but when i used this <if condition="fmod($post[postcount],2) == 0"> it gave me this error
The following template conditional expression contains function calls:
With a few exceptions, function calls are not permitted in template conditional expressions. Please go back and re-write this expression.
can any one suggest how to display adsense after every second post?
CyberAlien
02-24-2007, 06:22 PM
Try <if condition="($post[postcount] % 2) == 0">
jcodemasters
02-24-2007, 07:26 PM
Try <if condition="($post[postcount] % 2) == 0">
You rock.. one last question how to check last post .. thanks again for your reply
i got it..
<if condition="(($post[postcount]==1) or ($post[islastshown] and !$GLOBALS['vbulletin']->GPC['ajax']))">
turkerm
02-24-2007, 10:28 PM
Hi there!
This one rocks. I searched throughout the net and find this. Thanks.
How can we implement this code for each page of a thread? Because it is only valid for the first post of a thread.
Thanks!
jcodemasters
02-24-2007, 10:31 PM
this will work for first and last page of every post
<if condition="(($post[postcount] % $vboptions[maxposts] == 1) or ($post[islastshown] and !$GLOBALS['vbulletin']->GPC['ajax']))">
turkerm
02-24-2007, 11:03 PM
I put this
<if condition="$post[postcount] % $vboptions[maxposts] == 1">
Instead of
<if condition="$post[postcount] == 1">
It worked! Adsense is now shown on the first post of every page of every thread.
Thanks so much!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.