« HOWTO take apart and repair an old NES | Planet Lugs » |
François has written an Adsense plugin for b2evolution for conveniently inserting Google Ads via the insertion of an Adsense tag.
This approach allows one to manually and simply drop [ adsense: ]
tags throughout the post which will be automatically rendered as Google Ads.
Here is a method I found to add them on a more global level rather than manually adding in the post. You can also configure them based on each skin’s color scheme and dimensions.
First add a file that generates the Adsense code which I place in the skins folder with the rest of the base skin code.
<?php
global $gAdWidth, $gAdHeight, $gAdFormat, $gAdBorder, $gAdBgColor, $gAdLinkColor, $gAdTextColor, $gAdUrlColor;
if (isset($gAdWidth) && isset($gAdBgColor))
{
echo '<center>
<script type="text/javascript"><!--
google_ad_client = "pub-5883679897688490";
google_ad_width = '.$gAdWidth.';
google_ad_height = '.$gAdHeight.';
google_ad_format = "'.$gAdFormat.'";
google_ad_type = "text";
google_color_border = "'.$gAdBorder.'";
google_color_bg = "'.$gAdBgColor.'";
google_color_link = "'.$gAdLinkColor.'";
google_color_text = "'.$gAdTextColor.'";
google_color_url ="'.$gAdUrlColor.'";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></center>';
}
?>
Note: You can customise the above adsense code further, I believe there are a couple of other javascript parameters that you can add on the above code to further customise the Google ad.
Next you need to define those adsense settings at the skin level.
I add the following in the index.main.php file of the skin just after the
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directl$
Of course, put in the necessary values that fit your skin.
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directl$
$gAdWidth=468; // Width of the Ad
$gAdHeight= 60; // Height of the Ad
$gAdFormat = "468x60_as"; // Format of the Ad
$gAdBorder = "ffffff"; // Color of the Ad's border
$gAdBgColor = "ffffff"; // Color of the Ad's background
$gAdLinkColor = "000000"; // Color of the links in the Ad
$gAdTextColor= "222222"; // Color of the text in the Ad
$gAdUrlColor = "0000ff"; // Color of the Url in the Ad
You will need to look though the code and include the insertAdsense.php code where required.
include("insertAdsense.php");
For me, I added the above line in the following files
Most skins use the default base form files in the skins folder. However for skins with their own custom forms, you should find the respective files in the skins folder. After which simply insert the following variation of the above.
include(dirname(__FILE__)."/../insertAdsense.php");