Extension:ShoutWiki Ads
|
|
This extension requires patches to core MediaWiki code. Extensions implemented using patches may be disabled by or interfere with upgrades and security patches. If a suitable alternative without a patch is available, we recommend you use that extension instead. |
|
ShoutWiki Ads Release status: stable |
|||
|---|---|---|---|
| Implementation | User interface | ||
| Description | Displays Google AdSense ads on skins | ||
| Author(s) | Jack Phoenix | ||
| Last version | 0.2 | ||
| MediaWiki | 1.17+ | ||
| License | Public domain | ||
| Download |
Download snapshot (Git master)
Git [?]: repo summary • tree • code changes SVN [?]: checkout-url • tree • code changes #Version history |
||
| Example | ShoutWiki | ||
|
|||
|
|||
|
Check usage (experimental) |
|||
ShoutWiki Ads extension displays Google AdSense ads on skins. Currently it supports Monobook (requires patching), Monaco and Truglass skins.
The extension will not display ads
- when ads are disabled ($wgAdConfig['enabled'] = false;)
- on the login page (Special:UserLogin)
- on namespaces where ads are not enabled
- for autoconfirmed users
- if the wiki is in a language that is not supported by Google AdSense
This extension is currently very ShoutWiki-specific.
Contents |
[edit] History
The reason why this extension was written was that in the past, each skin (at ShoutWiki) that should have ads needed to implement its own ad loader, which was not very easy to maintain, as it meant lots and lots of code duplication. To solve the problem, we stashed all the ad-related code into one class, and we'd just hook on the different hooks in different skins to display the ads.
Of course, the Monobook skin didn't have the hooks we needed to use, so we had to create them.
All the functions in the ShoutWikiAds class are public and static, so it's very easy to use the class.
[edit] Installation
- Download the files and place them in $IP/extensions/ShoutWikiAds/
- Apply the patch against your $IP/skins/MonoBook.php
- Add the line
into the wiki's LocalSettings.php and configure the $wgAdConfig variablerequire_once("$IP/extensions/ShoutWikiAds/ShoutWikiAds.php");
- Installation can now be verified through the wiki's Special:Version
[edit] Patch
Index: MonoBook.php =================================================================== --- MonoBook.php (revision 88394) +++ MonoBook.php (working copy) @@ -98,7 +98,9 @@ <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?> <div class="visualClear"></div> </div> -</div></div> +</div> +<?php /* ShoutWiki patch */ wfRunHooks( 'MonoBookAfterContent' ); ?> +</div> <div id="column-one"<?php $this->html('userlangattributes') ?>> <?php $this->cactions( $skin ); ?> <div class="portlet" id="p-personal"> @@ -257,6 +259,7 @@ </div> </div> <?php + /* ShoutWiki patch */wfRunHooks( 'MonoBookAfterToolbox' ); } /*************************************************************************************************/
[edit] Parameters
The extension has only one configuration variable, $wgAdConfig. It should look something like this:
$wgAdConfig = array( 'enabled' => true, // enabled or not? :P 'adsense-client' => '', // provider number w/o the "pub-" part 'namespaces' => array( NS_MAIN, NS_TALK ), // array of enabled namespaces 'right-column' => true, // do we want a skyscraper ad column (Monobook)? 'toolbox-button' => true, // or a "button" ad below the toolbox (Monobook)? 'monaco-sidebar' => true, // 200x200 sidebar ad in the sidebar on Monaco skin 'monaco-leaderboard' => true, // leaderboard (728x90) ad in the footer on Monaco skin 'truglass-leaderboard' => true, // leaderboard ad for Truglass skin );
If the enabled key is set to false, the extension will do nothing.
The adsense-client key should be set to your AdSense provider number (just the number, not the "pub-" part!).
The right-column and toolbox-button options apply only to the Monobook skin. monaco-sidebar and monaco-leaderboard options apply only to the Monaco skin, while truglass-leaderboard option applies only to the Truglass skin.
[edit] Version history
| Version | SVN revision | Release date | Comments |
|---|---|---|---|
| 0.2 | r96255 | 4 September 2011 | ResourceLoader support added, backwards-compatibility with pre-1.17 MWs dropped |
| 0.1 | r87819 | 10 May 2011 | Initial release |