Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

GoogleAdsense

Summary:How to add Google AdSense data to your wiki
Version:0.1
Prerequisites:This should work for at least PmWiki 2.1 and up
Status:pre-alpha
Maintainer:XES
Categories:Includes

Questions answered by this recipe

How do I put my Google AdSense ads on my wiki site?

Description

Custom markup to pull in Google ads.

Notes

In config.php, I added:

//long google block markup
Markup('Google1', 'block',
        '/\\(:Google1:\\)/',
        Keep("<script type='text/javascript'><!--
google_ad_client = 'pub-########';
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = '120x600_as';
google_ad_type = 'text_image';
google_ad_channel ='';
//--></script>
<script type='text/javascript'
 src='http://pagead2.googlesyndication.com/pagead/show_ads.js'>
</script>"));

The trick is to change all the quotes in the Google paste text to single quotes, then place it within the double quotes of the Keep() function.

Note that I used 'pub-########' because this was done on a client's site and it's not my account number in the text. You will be given code by Google which will contain a number.

Then in a sidebar (I used the Triad skin's Site.RightBar:

(:Google1:)

Release Notes

  • 2006-11-12 - pre-alpha - just instructions, no downloads - XES November 12, 2006, at 12:51 PM

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

To Do

Make this a full plug-in style recipe where the orientation of the ads and the AdSense code can be pasted in to the markup, allowing different authors to have different AdSense codes in their own groups or pages on the same site.

Comments

I extended the recipe a bit so that you can fill in the size of your add. However I had to get ride of the Keep() function to get the variables substituted. Leaving out the Keep() doesn't seem to affect the good working of the code. But it will be interpreted by other layout rules which may have undesired effects.

//google adsense markup
// usage (:adsense <width> <height>:)
Markup('GoogleAdsense', 'block',
        '/\\(:adsense (\\d+) (\\d+):\\)/',
        "<script type='text/javascript'><!--
google_ad_client = 'pub-#####';
google_ad_width = $1;
google_ad_height = $2;
google_ad_format = '$1x$2_as';
google_ad_type = 'text';
google_ad_channel = '######';
//--></script>
<script type='text/javascript'
 src='http://pagead2.googlesyndication.com/pagead/show_ads.js'>
</script>") ;

Usage
(:adsense 468 60:)
Be aware that you can only use Google adsense permitted widths and heights e.g.
468 60
234 60
728 90

failing this will give a empty adsens space

Bart January 31, 2007, at 05:06 PM

Other extension proposal

I extended the GoogleAdsense recipe extended by Bart (see above). I had use of ParseArgs() to add different attribute to the markup. Thus you can have an heavy extented (:adsense <attributes>... :) markup in your wiki page or template page to have Google AdSense sponsorship.

New Features

  • (new) Support for XHTML page with "application/xhtml+xml" content-type.
  • (new) Support Google AdSense for referrals
  • (new) Support Google AdSense for searches
  • Every wiki page can hold different Google AdSense stuff
  • Separate configuration/customizations for per-group-customizations, for example:
    • in local/Site.php: $GoogleAdsenseChannel='chanelA';
    • in local/Cookbook.php: $GoogleAdsenseChannel='chanelB';

This recipe is available on my website: http://dfolio.free.fr/wiki/CookBook/GoogleAdSense. If you use, or have tested, this contribution, please send me your feedback. Thx.

Dfolio November 30, 2007, at 14:56 AM
Since my previous post was absolutly deprecated against the recipe proposed on my site, I just put above my proposed features.


See Also

Contributors

Edit - History - Print - Recent Changes - Search
Page last modified on November 30, 2007, at 08:05 AM