PDA

View Full Version : Show Thread Enhancements - Adsense as second post. 2 Sizes - Big for guests, small for members - Legacy Version


StarBuG
11 Feb 2007, 11:31
Hi

I made this template mod for my medical Forum and I decided to share this with you

This hack is for forums that use the Postbit_legacy Template

If you use the standard postbit template >> click here << (http://www.vbulletin.org/forum/showthread.php?t=136743)


What this hack does:
This modification displays adsense as second post in every thread.
Guest see a post like adsense with a product Referral (firefox in this code) and a leaderboard as post content. Registered Members see a standard banner so they don't get annoyed by the big advertising. I also included an information for guests, that they see a different not so disturbing ad if they register. This serves to purposes, one is to get more members to register of course the second purpose is to blend the advertising better into the post layout.

ADD-ON:
In addition you can add a Google Adsense link unit as last post of a thread on any page for members and guests. This advertising will only show if the thread has more then one post so that it does not show 2 advertisings directly below each other in case that the thread has no replies yet. Google Adsense has updated its ToS so that you are now allowed to use up to three link units on one page. So if you already use my "Adsense Link Unit in Navbar (http://www.vbulletin.org/forum/showthread.php?t=146581)" Mod there woun't be a problem.


See screenshots ;)

How to install:


In template postbit (legacy version) search:



<if condition="$post['userid'] AND $show['member']">
<tr><td class="vbmenu_option"><a href="profile.php?$session[sessionurl]do=addlist&amp;userlist=buddy&amp;u=$post"><phrase 1="$post[username]">$vbphrase[add_x_to_buddy_list]</phrase></a></td></tr>
</if>
</table>
</div>
Add below:



<!-- Google AdSense in Posts for Guests -->
<if condition="THIS_SCRIPT == 'showthread' AND !$GLOBALS['FIRSTPOSTID'] AND (!$show[member])">

<if condition="$show['spacer']">
</div>
$spacer_close
</if>

<if condition="$show['spacer']">
$spacer_open
<div id="edit$post[postid]" style="padding:0px 0px $stylevar[cellpadding]px 0px">
</if>

<!-- BEGIN TEMPLATE: postbit -->
<table id="post$post[postid]" class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="0" border="0" width="100%" align="center">
<tbody>
<tr>
<td class="thead" style="font-weight:normal; border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-right: 0px" $post[scrolltothis]>
<!-- status icon and date -->
<img title="Alt" class="inlineimg" src="images/statusicon/post_old.gif" alt="Alt" border="0"> Today
<!-- / status icon and date -->
</td>
<td class="thead" style="font-weight:normal; border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-left: 0px" align="$stylevar[right]">
</td>
</tr>
<tr valign="top">
<td class="alt2" width="175" style="border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-top: 0px; border-bottom: 0px">
<div id="postmenu_$post[postid]">
<span class="bigusername"><u><font color="#373737">Advertising</font></u></span>
<br><br>
<!-- Adsense Referral Code start -->
<script type="text/javascript"><!--
google_ad_client = "YOUR PUB ID HERE";
google_ad_width = 125;
google_ad_height = 125;
google_ad_format = "125x125_as_rimg";
google_cpa_choice = "CAAQ0f2XhAIaCA6IC4oIlz0_KK2293M";
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<!-- Adsense Referral Code end-->
</div>
</td>
<td class="alt1" id="td_post_$post[postid]" style="border-right: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
<!-- icon and title -->
<div class="smallfont">
<img title="Post" class="inlineimg" src="images/icons/icon1.gif" alt="Beitrag" border="0">
<strong>Sponsored Links</strong>
</div>
<hr size="1" style="color:$stylevar[tborder_bgcolor]" />
<!-- / icon and title -->
<!-- message -->
<div>
<!-- Adsense leaderboard start -->
<script type="text/javascript"><!--
google_ad_client = "YOUR PUB ID HERE";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<!-- Adsense leaderboard end -->
</div>
<!-- / message -->
<!-- sig -->
<div>__________________<br>
<i>This advertising will not be shown in this way to registered members.<br />
<a href="register.php">Register</a> your free account today and become a member on $vboptions</i>
</div>
<!-- / sig -->
</div>
<!-- / message -->
</td>
</tr>
<tr>
<td class="alt2" style="border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-top: 0px">
&nbsp;
</td>
<td class="alt1" align="$stylevar[right]" style="border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-left: 0px; border-top: 0px">
&nbsp;
</td>
</tr>
</tbody></table>
<!-- / post $post[postid] popup menu -->
</if>
<!-- / Google AdSense in Posts for Guests-->

<!-- Google AdSense in Posts for Members -->
<if condition="THIS_SCRIPT == 'showthread' AND !$GLOBALS['FIRSTPOSTID'] AND ($show[member])">

<if condition="$show['spacer']">
</div>
$spacer_close
</if>

<if condition="$show['spacer']">
$spacer_open
<div id="edit$post[postid]" style="padding:0px 0px $stylevar[cellpadding]px 0px">
<if condition="!$post['islastshown']"><!-- this is not the last post shown on the page --></if>
</if>

<table class="tborder" id="post$post[postid]" align="center" border="0" cellpadding="6" cellspacing="1" width="100%">
<tbody><tr>
<td class="thead" id="td_post_$post[postid]">
<div class="normal">
&nbsp;
</div>
</td>
</tr>
<tr>
<td class="alt1" align="center">
<div>
<!-- Adsense standard banner start -->
<script type="text/javascript"><!--
google_ad_client = "YOUR PUB ID HERE";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<!-- Adsense standard banner End -->
</div>
</td>
</tr>
</tbody>
</table>
</if>
<!-- / Google AdSense in Posts for Members-->
[U]ADD-ON:


Add this code below the last line of my above code:



<!-- Google AdSense Link unit as last post for all -->
<if condition="THIS_SCRIPT == 'showthread' AND $post['islastshown'] and !$GLOBALS['vbulletin']->GPC['ajax'] AND $post[postcount]!=1">

<if condition="$show['spacer']">
</div>
$spacer_close
</if>

<if condition="$show['spacer']">
$spacer_open
<div id="edit$post[postid]" style="padding:0px 0px $stylevar[cellpadding]px 0px">
<if condition="!$post['islastshown']"><!-- this is not the last post shown on the page --></if>
</if>

<table class="tborder" id="post$post[postid]" align="center" border="0" cellpadding="6" cellspacing="1" width="100%">
<tbody><tr>
<td class="thead" id="td_post_$post[postid]">
<div class="normal">
&nbsp;
</div>
</td>
</tr>
<tr>
<td class="alt1" align="center">
<div>
<!-- Adsense Link Unit start -->
<script type="text/javascript"><!--
google_ad_client = "YOUR PUB ID HERE";
google_alternate_color = "F5F5FF";
google_ad_width = 728;
google_ad_height = 15;
google_ad_format = "728x15_0ads_al_s";
google_color_border = "F5F5FF";
google_color_bg = "F5F5FF";
google_color_link = "000000";
google_color_text = "000000";
google_color_url = "000000";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<!-- Adsense Link Unit end -->
</div>
</td>
</tr>
</tbody>
</table>
</if>
<!-- Google AdSense Link unit as last post for all -->
You now just need to customize the adsense code marked with:
<!-- Adsense Referal Code start -->
<!-- Adsense large rectangle start -->
<!-- Adsense standard banner start -->


Add-on:
<!-- Adsense Link Unit start -->

replace "YOUR PUB ID HERE" with your pub-ID
and fit the colors of adsense to your color scheme


Demo: Elternfragen.net - Das Forum für Eltern mit (medizinischen) Fragen (http://www.elternfragen.net)

Just go into any thread.


I hope you like it and if you do, don't forget to mark es installed ;)


Changelog:
v1.15 - 2007/07/22: NO CHANGES, just removed my Pub-ID from the hack!
v1.15 - 2007/06/11: Add-on - Google Adsense Link unit as last post of every thread for guests and members.
v1.1 - 2007/05/06: Condition altered to show advertising as second post on every page, not just the first.
v1.0 - 2007/03/01: Changed a few German phrases to English, removed an unneccessary condition


If you want more good placements for adsense code, check out my newest mod:


Adsense Link Unit in Navbar (http://www.vbulletin.org/forum/showthread.php?t=146581)


StarBuG

[B]If you did not register for an Adsense account yet but you plan to, feel free to contact me. If you register via my referral I am willing to help you get the most out of your adsense placement by assisting you during the setup process and implementing the best adsense modifications. Just write me a Private message.

insolentmuse
11 Feb 2007, 17:36
Thank you so much :)

StarBuG
12 Feb 2007, 06:45
You'r welcome ;)

insolentmuse
12 Feb 2007, 07:50
Works like a charm, btw.

4x4 Mecca
28 Feb 2007, 23:55
Sort of installed, modified it a little and made it not show for members at all.

Thanks for the idea. :)
Me too, and changed the language to English, and changed the register link to a user I created to I can track registration through the link. Thanks!

StarBuG
01 Mar 2007, 04:50
Oh, I missed a few german phrases, I have fixed that now.

StarBuG

TheFrienzNet
07 Mar 2007, 16:56
Mm, whenever I install it, the style gets messed up and the ads goes where the second username is. (Screen (http://img408.imageshack.us/img408/5933/unic2.png))

StarBuG
08 Mar 2007, 04:41
Do you use the legacy version of the postbit template?

Did you add the code below the above mentioned code?

jmw
08 Mar 2007, 21:17
Ok, showing fine. Gotta change the username "Heute". I assume I can do that by editing this user in vbcp right?

Volvoholic
14 Mar 2007, 16:06
Hi,

Works great. I am new to Vbulletin and I did it without any hitches. Very easy to understand. However, I have three points to make.

1. I use a sub-style and it only worked if I modified the parent style's Postbit template. Is this correct? Did not work (nothing happens) when I only modified the sub style.

2. Does the google adsense code generate ads based on the thread content? Does this mean different threads will have different ads? If not how do I configure the ads to be based on the thread content.

3. Where and what do I look for if I want to change the type of users who see the firefox ads? My forum threads are not viewable to guests (for privacy) and they have to register to view threads (in the general areas only), full members have to email me and I join them in a usergroup for full access. How do I enable only registered members & guests to view the firefox ads?

Thanks. Keep up the great work and I for one really appreciate it. like I said before, works great.

V

StarBuG
15 Mar 2007, 17:01
@jmw: heute means "Today" and you don't need to create a user for this hack. I simply missed to translate the german phrase (it's fixed now ;))

@Volvoholic:
1) no it should work in the child style if you changed it in that postbit. Did you switch your forum view to that specific style?

2) yes. Google adsense is content based and it will show different ads for different threads.
read google help or visit webmaster communities like www.theadminzone.com or www.digitalpoint.com for more infos and tips about adsense

3) that is generaly a bad idea because google is a guest too. If you block guest views google can't index your forum (you lose new visitors) and can't deliver targeted ads (you lose money).

replace the condition at the beginning of my code with:

<if condition="THIS_SCRIPT == 'showthread' AND $post[postid] == $GLOBALS['qrfirstpostid'] AND ($show[member]) AND $bbuserinfo['usergroupid'] == 'X'">


and the X in $bbuserinfo['usergroupid'] == 'X' with the ID of the usergroup you want to see the ad

Volvoholic
15 Mar 2007, 21:51
StarBug

thanks, i was not getting google targeted ads because my forum view is closed for guests. Thanks for that info.

Cheers
V

Atakan KOC
26 Mar 2007, 09:23
Thanks........

AzaDiyaR
26 Mar 2007, 10:38
nice thank you so much :D

Lars-Christian
02 Apr 2007, 22:06
I don't know if this is because I have some other modifications installed, but this breaks the multiquote feature on my boards for the posts below the AdSense ad. Can anyone else with it installed check to see if it's just on my board?

Edit: Nevermind. I managed to fix it - It had something to do with my postbit_wrapper template being screwed, but I figured it out :)

jmw
17 Apr 2007, 21:59
@jmw: heute means "Today" and you don't need to create a user for this hack. I simply missed to translate the german phrase (it's fixed now ;))

lol, thanks Starbug. What if I want to show the same ads to all users? To members and guests...

Mrdby
17 Apr 2007, 22:50
starbug can you help me?

HeRmAn'S
18 Apr 2007, 13:44
*Installs* ...and good working :D StarBug :up:

Mrdby
18 Apr 2007, 13:47
*Installs* ...and good working :D StarBug :up:

can i see how your looks?

StarBuG
18 Apr 2007, 16:38
@Mrdby: That totally depends on your problem. First step would be to tell me where I should help you ;)
Edit: Wrong thread. Check my reply in the other thread ;)

@jmw: remove the condition "AND (!$show[member])" and the whole 2nd part (either the member or guest part), depending on which advertising you want to show.

Mrdby
18 Apr 2007, 16:40
@Mrdby: That totally depends on your problem. First step would be to tell me where I should help you ;)

@jmw: remove the condition "AND (!$show[member])" and the whole 2nd part (either the member or guest part), depending on which advertising you want to show.
lOL..Well i mean helping me add it in my post bit...BUT i copied and pasted the code you gave...right below whatever was asked...and a google ad came up and nothing else.

South Fork
19 Apr 2007, 23:20
Very nice, thanks. Installs.

StarBuG
06 May 2007, 08:44
I have changed the condition to show the advertising on every page as second post, not just on page one.

The old condition was:

<if condition="THIS_SCRIPT == 'showthread' AND $post[postid] == $GLOBALS['qrfirstpostid'] AND ($show[member])">
the new condition is:

<if condition="THIS_SCRIPT == 'showthread' AND !$GLOBALS['FIRSTPOSTID'] AND ($show[member])">
Simply replace the old conditions (2x) with the new one and the ads will show on every page of every thread as second post.

StarBuG

The hack is now version 1.1

Best regards

StarBuG

HeRmAn'S
07 May 2007, 10:32
can i see how your looks?prove picturize ...last version 3,6,5 ...look picture :rolleyes:;) ...and good work :cool:

StarBuG
11 Jun 2007, 10:52
I have just released an add-on for this mod.


ADD-ON:
In addition you can add a Google Adsense link unit as last post of a thread on any page for members and guests. This advertising will only show if the thread has more then one post so that it does not show 2 advertisings directly below each other in case that the thread has no replies yet. Google Adsense has updated its ToS so that you are now allowed to use up to three link units on one page. So if you already use my "Adsense Link Unit in Navbar (http://www.vbulletin.org/forum/showthread.php?t=146581)" Mod there woun't be a problem.

I hope you like it.

Let me know how it works out ;)

StarBuG

Fireproof
11 Jun 2007, 22:45
How does Google check for content to display content-relevant ads? Mine appears to not be working - it seems to ignore all the thread content. Every add is the same on all forums and is advertising "clutches" since my site title is Clutch Fitness.

StarBuG
12 Jun 2007, 04:50
They have a spider to fetch your content.
But it normaly takes 2-3 weeks for the ads to get relevant if you just started display them.

almightyone
25 Jun 2007, 00:41
is there a way to keep this from showing in some forums i dont want it in my staff area or some other forums

StarBuG
25 Jun 2007, 18:11
You could exclude forums by changing the condition like:

<if condition="THIS_SCRIPT == 'showthread' AND !$GLOBALS['FIRSTPOSTID'] AND (!$show[member])" AND !in_array($forum[forumid], array(16,17,18,19)>


replace 16,17,18,19 with the forum IDs you don't want the ad to show

StarBuG

almightyone
25 Jun 2007, 21:34
thnx man i will try this out

almightyone
25 Jun 2007, 21:44
it didnt work for me i will do it on my test board later and post the error but it said a conditional error was there and none of my posts showed on my forums when viewing them

almightyone
25 Jun 2007, 21:52
works fine without using the forums conditions

elpadrecito
26 Jun 2007, 03:14
Thank you much! Wow, almost spiritual!:)

ayoko555
26 Jun 2007, 05:39
Thank you so much! Could anyone teach me how to not show ads to members at all please?

StarBuG
27 Jun 2007, 05:04
Thank you so much! Could anyone teach me how to not show ads to members at all please?

Remove all the code after:

<!-- Google AdSense in Posts for Members -->

siliconfinance
29 Aug 2007, 08:00
Anybody know whether this works on 3.6.8, I have the following code at the end of the postbit legacy template:

<if condition="$post['userid'] AND $show['member']">
<tr><td class="vbmenu_option"><a href="profile.php?$session[sessionurl]do=addlist&amp;userlist=buddy&amp;u=$post[userid]"><phrase 1="$post[username]">$vbphrase[add_x_to_buddy_list]</phrase></a></td></tr>
</if>
$template_hook[postbit_user_popup]
</table>
</div>
<!-- / post $post[postid] popup menu -->

When I insert the adcode, it displays after every post.

siliconfinance
29 Aug 2007, 10:01
Ok, I got your code to work. I have always used this expression in the past to exclude certain groups from seeing the ads:

<if condition="!is_member_of($bbuserinfo, 6, 7)">

Unfortunately, when I replace your conditional code with the above conditional code, then it displays ads after every post.

StarBuG
29 Aug 2007, 15:15
You can't replace it, you need to ADD it to my condition ;)

Kaelon
15 Sep 2007, 05:23
I saw that the avatar image for the Advertising post (for guests) is a Firefox emblem.

Is that served by Google? Are there any valid 125 x 125 ad units that would ever be served there? Are there other 125 x 125 items that I can use? And, do you know of any way to customize the google_cpa_choice parameter?

StarBuG
15 Sep 2007, 09:05
Yes, there are lots of Referral Images in all sizes and for numerous products.
I did not made the FF banner myself ;)

What do you mean by "google_cpa_choice parameter"?

Kaelon
15 Sep 2007, 16:56
Yes, there are lots of Referral Images in all sizes and for numerous products.
I did not made the FF banner myself ;)

What do you mean by "google_cpa_choice parameter"?
Rather, that the google_cpa_choice in the referral image was what brought up the Firefox image. I wanted to select a different image. Is that possible? Or was Google simply cycling them around?

hrk
17 Sep 2007, 17:29
hi. how do i see mine is posbit or legacy template?

thanks,:)

StarBuG
18 Sep 2007, 15:38
legacy is where the user info is on the left of the post, in normal postbit the user info is on top of the post.

hrk
25 Sep 2007, 17:03
legacy is where the user info is on the left of the post, in normal postbit the user info is on top of the post.

thanks mate! :)

mark|3
13 Dec 2007, 09:09
hi starbug

here's is my site. Possible to guide me on how to go about changing the background color of the advert.

Thanks

StarBuG
13 Dec 2007, 10:49
The color code for the adsense Ads is in the Google Code itself:

Go to your Adsense Setup and create the Banner you want, there you'll find all the options for changing the colors. Replace the current code with the newly generated code and you are good to go.

Ah, one more thing.
You use a leaderbord Banner inside the Navigation, that is not a good choice.

Put it below the navigation and inside the link unit like in my hack you seem to use.
Much better results.

To add a leaderboard banner below the navigation

In the navbar Template search for:


<!-- / PAGENAV POPUP -->
</if>
and add below:


<!-- 728x90 Leaderboard below navigation-->
<if condition="THIS_SCRIPT != 'index'">
<table class="tborder" align="center" border="0" cellpadding="6" cellspacing="1" width="100%">
<tbody>
<!-- <tr>
<td class="tcat" align="center"></td>
</tr> -->
<tr>
<td class="alt1" colspan="2">
<span class="smallfont">
<center>
YOUR ADSENSE LEADERBOARD CODE HERE
</center>
</span>
</td>
</tr>
</tbody>
</table><br />
</if>
<!-- 728x90 Leaderboard below navigation -->
StarBuG

McCarroll21
13 Dec 2007, 15:01
My question is probably a simple one; though I'm not really sure. I really think I'm just overlooking something, but can't find what it is I'm looking over.

I have tested this time and time again and can't get it to show how I want it. I want to do the after first post AND after the last post. I want it to show for everyone (members and guests alike). My problem is that I get it to show, but if I have a thread that only has one post showing on one page (let's say it has 31 posts in it, so on page 4 it only has one post) I get both boxes showing up when I only want it to show one.

How could this condition be modified to where it will not show if there is only one post on the current page? I know it has if the thread only has one post, but what about one post on the current page?
<if condition="THIS_SCRIPT == 'showthread' AND $post['islastshown'] and !$GLOBALS['vbulletin']->GPC['ajax'] AND $post[postcount]!=1">

Thanks!

StarBuG
13 Dec 2007, 22:41
You could add AND $post[postcount]!=31 at the end of the condition.

But this is not an elegant solution.

I have no idea how to solve this issue because the page break depends on your settings.
I think you should ask in the programmers forum here on vB.org, if someone knows a solution.

mark|3
14 Dec 2007, 18:37
thanks for the solution :D
but now i have another problem bec there's a space between the banner. Any idea on how to prevent the gap between the navbar and the advert?

Thanks

StarBuG
14 Dec 2007, 20:32
I would leave the break between the navbar and the banner, that is a much cleaner display.

However, if not, check in the navbar template above the search code, there must be a <br /> that you need to remove

se_p800
04 Jun 2008, 16:58
this works fine for 3.7.1 btw!

F0xy
19 Jun 2008, 21:21
how do you get this to be set up for all guests and all members
http://www.vbulletin.org/forum/attachment.php?attachmentid=60379&d=1171197550

StarBuG
20 Jun 2008, 13:08
Change

<if condition="THIS_SCRIPT == 'showthread' AND !$GLOBALS['FIRSTPOSTID'] AND (!$show[member])">

to

<if condition="THIS_SCRIPT == 'showthread' AND !$GLOBALS['FIRSTPOSTID']">

:)

F0xy
20 Jun 2008, 14:38
good man, thanks

sunnylikbeckham
06 Sep 2008, 19:17
hey cool man
in bigger banner for guests
can you tell me how can i fill the place on its right
bcz what ever code i put next come in next line
thanks

StarBuG
14 Jan 2009, 21:34
use a table and put both codes each in a td ;)

Riccardo83
02 Feb 2009, 10:56
Yeah it's great. I mean the code works... Hope he still does updates for the 3.8.0 although this version has adsense support itself.... didnt test it yet tho....

hieuhpp
05 Feb 2009, 13:28
when i use:
<if condition="THIS_SCRIPT == 'showthread' AND !$GLOBALS['FIRSTPOSTID'] AND (!$show[member])" AND !in_array($forum[forumid], array(16,17,18,19)>
have error :

The following error occurred when attempting to evaluate this template:

The conditional on line 284 appears to be missing its beginning tag (<if>). This may cause unexpected behavior.


This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.

rtyagis
29 Oct 2009, 12:02
Thanks ... Installed. But the Adsense is not showing for guests and members both any specific reason. I use Vbullitin integrated Adsense.

otectom
27 Aug 2011, 19:23
I am having trouble installing this mod. In my templates I cannot find

<if condition="$post['userid'] AND $show['member']">
<tr><td class="vbmenu_option"><a href="profile.php?$session[sessionurl]do=addlist&amp;userlist=buddy&amp;u=$post[userid]"><phrase 1="$post[username]">$vbphrase[add_x_to_buddy_list]</phrase></a></td></tr>
</if>
</table>
</div>

anywhere. I have looked in multiple templates and have tried using the search templates tool, but with no luck. Does this mod work in vb4? What template (specifically) are you editing?