Extension:Google AdSense 2
From MediaWiki.org
|
Release status: stable |
|||
|---|---|---|---|
![]() |
|||
| Implementation | Skin | ||
| Description | Adds GoogleAdSense to the sidebar | ||
| Author(s) | Siebrand Mazeland (SiebrandTalk) | ||
| Last Version | 1.1 (2008-11-27) | ||
| MediaWiki | 1.14 or newer | ||
| License | MIT | ||
| Download | Download snapshot |
||
| Example | translatewiki.net | ||
|
|||
|
|||
|
check usage (experimental) |
|||
Contents |
[edit] Description
Enables easy addition of Google AdSense advertisements to a MediaWiki instance. See screenshot and Installation for details. This extension requires an account with Google's AdSense.
[edit] Installation
- Download the extension
- Add the following lines to your LocalSettings.php (replace the text where directed)
require_once( "$IP/extensions/GoogleAdSense/GoogleAdSense.php" ); $wgGoogleAdSenseClient = 'replace this with the client name'; $wgGoogleAdSenseSlot = 'replace this with the slot name'; $wgGoogleAdSenseID = 'replace this with your ID';
Example settings
$wgGoogleAdSenseClient = 'pub-8330046405419293'; $wgGoogleAdSenseSlot = '1640430293'; $wgGoogleAdSenseID = 'yourwiki-2';
- Add any of the optional settings below, if your settings deviate from the defaults
// Width of the AdSense box, specified in your AdSense account $wgGoogleAdSenseWidth = 120; // Height of the AdSense box, specified in your AdSense account $wgGoogleAdSenseHeight = 240; // Source URL of the AdSense script $wgGoogleAdSenseSrc = "http://pagead2.googlesyndication.com/pagead/show_ads.js"; // Show the AdSense box only for anonymous users $wgGoogleAdSenseAnonOnly = true;
- Add the following CSS code to MediaWiki:Common.css (also in file GoogleAdSense.css)
/* Pad Google AdSense box in portlet in sidebar */ #p-googleadsense .pBody { padding-top: 5px; text-align: center; }
- The description (label) of the portlet can be changed in [[MediaWiki:Googleadsense]]. Defaults to "Google AdSense".
[edit] How to install on Mediawiki prior to 1.14
Note: This is not official code and it was tested on 13.x mediawiki only. Use it at your own risk!
Open ./include/Skin.php file and find buildSidebar function at the end.
Insert next code
// Port from 1.15
wfRunHooks('SkinBuildSidebar', array($this, &$bar));
prior to
if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
And ads should work.
