Adsense for PHPBB 3.0 - Inline & First Post
|
|
by
I show you something fantastic and you find fault.
Published on April 6th, 2007, 12:52 pm Rift: Advice |
This Adsense Modification works differently than other codes you've seen posted as it checks to see if the dynamic page being generated is a post or a topic. If it's a post it doesn't show the ad. Why? Because generally most of the time the only reason a reader will be on a post page is when they've just replied, or edited a page. They've already seen the ad. Because each post generates an individual URL for each post, the viewer will only be seeing a single untargeted ad. The bot which will later come by and download the page wastes bandwidth, and since it's unlikely the page will be ever served again, we turn it off. This increases your CTR, and benefits you by increasing the value of your AdSense landing pages.
This of course doesn't address your index, or viewforum, but a similar approach could be made. Since most of the revenue seems to come from the topic pages themselves, this is a perfect approach.
To use this code, just follow the instructions below, and replace the pub-id in the AdSense code currently (12345) to your own:
Change this, in the code below:
- Code: Select all
google_ad_client = "pub-12345";
Should take you all of 5-10 minutes to get this working. You may also choose to adjust the IP to block ads to yourself.
The latest addition is the code that disables the AdSense on users with greater than a 3 posts. You can change the 3 in the code to the number you like, and at users with post counts greater than that number receive no ads.
Open Viewtopic.php and find:
- Code: Select all
// Send vars to template
Before that line add this:
- Code: Select all
// ADSENSE for PHPBB 3.0 by Liv Jones - February 7, 2010
// Support for this modification can be found at:
// http://greensboring.com/viewtopic.php?f=23&t=4299
// BEGIN ADSENSE CODE
if (empty($_REQUEST['p']) && empty($_REQUEST['sid']) && empty($_REQUEST['hilit']) ) {
$adsense=<<<EOD
<script type="text/javascript"><!--
google_ad_client = "pub-12345";
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = "300x250_as";
google_ad_type = "text_image";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "000080";
google_color_text = "000000";
google_color_url = "DDDDDD";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
EOD;
$adsense2=<<<EOD
<script type="text/javascript"><!--
google_ad_client = "pub-12345";
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = "300x250_as";
google_ad_type = "text_image";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "000080";
google_color_text = "000000";
google_color_url = "DDDDDD";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
EOD;
if (isset($user->data['user_id']) && $user->data['user_id'] != 1 && isset($user->data['user_posts']) && $user->data['user_posts'] > 3) { $adsense='';
$adsense2='';
}
}
//block self
// change to your IP to block ads to yourself and prevent accidentally clicking on them.
$self="24.148.149.208";
if ($_SERVER['REMOTE_ADDR'] == $self) {
$adsense='';
$adsense2='';
}
//block self
// block certain forums
if ($forum_id == 27 || $forum_id == 28) {
$adsense='';
$adsense2='';
}
// Licensing:
// Please help a girl and her family out by providing a link for using this script even if you remove this line.
$adsense=$adsense.'<br><small><small><small><a href="http://greensboring.com/">Ad Software by Greensboring.com</a></small></small></small>';
$template->assign_vars(array('AD_SENSE' => $adsense, 'AD_SENSE2' => $adsense2));
// END ADSENSE FOR PHPBB MOD
Open your viewtopic_body.html Template in the ACP, and add this in your template where you want the ad to appear. I prefer the 300x250 ad inside the first post. This can be done by searching for this:
- Code: Select all
{postrow.MESSAGE}
And Above it (or right before it) add this:
- Code: Select all
<!-- IF postrow.S_FIRST_ROW -->
<div style="float:left;">
{AD_SENSE}
</div>
<!-- ENDIF -->
You can also use the second Adsense variable else where in your template such as below the posts, such as:
- Code: Select all
{AD_SENSE2}

