Please wait, Page is Loading...
 

GoogleAdSense

News:

  • Version 1.3 (2007/11/30)
  • Adding support for true XHTML page,
    with "application/xhtml+xml" content-type

Based On:PmWiki Cookbook GoogleAdsense
Summary:How to add Google AdSense data to your wiki
Prerequisites:This should work for at least PmWiki 2.1 and up
Maintainer:XES, Dfolio
Categories:PHP | PmWiki
Download:CookBook/googleadsense.php[CookBook/googleadsense.php] Type: application/x-php Taille:11,45 Ko Dernière modification:30/11/2007 14:52Mime:php (md5sum: c55eaf231e74e61057a29a6cfa509344)

Description

Custom markup to pull in Google AdSense
I extended the GoogleAdsense cookbook, available from PmWiki Cookbook, which has been extended by Bart. Thus you can use the (:adsense <attributes>... :) markup in your wiki page or template page to have Google AdSense sponsorship.

Features

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

Howto get it work

First, download: CookBook/googleadsense.php[CookBook/googleadsense.php] Type: application/x-php Taille:11,45 Ko Dernière modification:30/11/2007 14:52Mime:php. Then put CookBook/googleadsense.php[CookBook/googleadsense.php] Type: application/x-php Taille:11,45 Ko Dernière modification:30/11/2007 14:52Mime:php in the PmWiki $FarmD/cookbook/ directory, and add the the following line to /local/config.php:

include_once("$FarmD/cookbook/googleadsense.php");

Configuration:

This contribution provide the following customizable variable

  • $GoogleAdsenseClient: to specify the default Google AdSense client ID
    WARNING If this variable is not defined AND if they are no id field on your markup NO OUTPUT is produced
  • $GoogleAdsenseChannel: to choose your channel
  • $GoogleAdsenseBGcolor: to change the background-color property
  • $GoogleAdsenseUIfeatures: to change the UI features property

Example of configuration file:

...
##define the default adsense client ID
$GoogleAdsenseClient='pub-XXXXXXXXX';
##define the default adsense channel
$GoogleAdsenseChannel='xxxxxxx'
## customize adsense BG color
$GoogleAdsenseBGcolor='f7f7fd';
include_once("$FarmD/cookbook/googleadsense.php");
...

Per-group-customizations

Don’t hesitate to use per-group-customizations to optimize your Google AdSense.
For example to specify different channel for the Site and Cookbook group:

  • in local/Site.php:
...
 $GoogleAdsenseChannel='channelA';
...
  • in local/Cookbook.php:
...
 $GoogleAdsenseChannel='channelB';
...

(new) Using XHTML & application/xhtml+xml

I have added new configuration variable, which for me work as a general configuration variable in my PmWiki settings.

The first one: $ContentType, allow you to specify your content type definition. By default its set to text/html, which is the best way to use Google AdSense. Nevertheless, if you want, as this site, to use strict XHTML with the good content-type: application/xhtml+xml, the default Google AdSense scripts fail to display anything.

Why won’t AdSense work with true XHTML?

Google’s AdSense works by using JavaScript to generate an iframe in which to dynamically serve advertisments. This is fine if the page is going to be regular HTML or non-strict versions of XHTML being served as text/html. The JavaScript generates the iframe as expected, and everything works fine and dandy. Unfortunately, for webmasters serving XHTML pages as application/xhtml+xml, the Google method doesn’t work.

Making AdSense work with XHTML (source: http://keystonewebsites.com/articles/adsense.php)


Thus, I use a hack based on "Making AdSense work with XHTML" which appears to be compliant with google adsense policies at this time.

This cookbook is provided "AS IS " and any express or implied waranties against the google adsense policies are disclaimed. If in the future the above hack appears to not be compliant with google adsense policies, YOU are responsible for regularly reviewing the google adsense policies.
If you don’t want use this hack, simply leave: $ContentType='text/html'; in your configuration file.

I have also added $IsJsEnabled, allow you to (dis)enable JavaScripts content on your pages. By default, in this cookbook SDV($IsJsEnabled,1); (ie JavaScripts is enabled). If it’s disabled then ALL Google AdSense content are not displayed…

Markup Usage

This Google AdSense markup support the following attributes:

  • [ id, client ]: select a client ID
  • (new) [ slot ]: handle Google AdSense slot
  • [ channel, chan ]: select a channel
  • (new) [ cpa, cpa_choice ]: handle Google AdSense for referrals
  • [ width, w ] and [ height, h ] : select a size
  • type: select a type (text/image)
  • [ bg, background ]: select a background
  • [ ui, ui_features ]: select a UI features provide by Google AdSense

Of course you can mixed the attribute describe above, according the following condition

  • There are no order restriction
  • They are sensitive case: all attribute MUST be in lowercase
  • In case of multiple value, the last one is use, for example:
    • (:adsense type=text_image type=text:) the type attribute is set to text
    • (:adsense width=500 ... w=150 :) the width attribute is set to 150

Example:

  • (:adsense id=XXXXX channel=channelA :), (:adsense chan=channelB type=text :)
  • (:adsense w=468 height=60 backgground=#FF7700 :), (:adsense bg=#123456 type=text_image:)
  • (:adsense width=468 height=60 :), (:adsense h=90 w=728 chan=channelA+channelB :)

Tips

A simple way to add this markup to your wiki page is to add it to the ${SiteGroup}.SideBar (see usage above).
But you can also embedded this markup in your template (eg. .tmpl file). To this aim edit your template file, eg. pub/skins/<YOU_RSKINS>/<SKIN_TEMPLATE>.tmpl, and add the following line somewhere :

<!--markup:(:adsense type=text_image bg=f7f7fd ui=rc:6 :)-->

Google Adsense & Searches

Google Adsense also handle searches. Thus I have extend this recipe to handle Google Adsense Searches, by adding the markup: (:adsearch ...:) .

Usage

This Google AdSense Search markup support the following attributes:

  • [ id, client ]: select a client ID
  • [ channel, chan ]:select a channel
  • [ lang, language, hl ]:select the language (default use userlang, see Cookbook:MultiLanguage)
  • safe=active: enable safe search
  • charset: choose the charset
  • cof: specify the COF field

See also


« Down | CookBook | Xhtml Validator »

Commentaire

Remark, suggestion post a comment:

Carlos — 13 fvrier 2008, 21:47

Cool stuff. Thank you for that.

Twyst16 April 2008, 21:29

As a heads up, you’ve mistakenly used function_exist on line 223 - it should be function_exists.

sexgamesall20 mai 2008, 05:07link

. , , , ,

OlfrmKOKN05 June 2008, 11:05GAIhlBOxCwqNXlrRl

forum.facka.ru.txt;2;9

zrrAszubRRBLr07 juin 2008, 12:08sGwvOkBBOIIItzC

fo069.txt;3;6

kabindra13 July 2008, 07:02www.computer-drm.blogspot.com

The best site to get all the latest information about the computer technology

xSFRiRxragGT25 juillet 2008, 01:41TipvWNmDLIcdunr

fo103.txt;3;6

Gartman609 avril 2009, 01:56link

Just do it: ,

Signer en tant qu'auteur 
Website 

Veuillez indiquer un nom d'auteur, et entrer la valeur du code (limite le spam...). Merci.


  • Add This
  • Add
  • Get
  • Google

default