Extension:AdsWherever
From MediaWiki.org
|
AdsWherever Release status: unstable |
|
|---|---|
| Implementation | Tag |
| Description | Display Ads wherever with a tag <ads> |
| Author(s) | Wikimama |
| Last version | 1 (2011-04-12) |
| MediaWiki | 1.15 |
| License | GPL |
| Download | see below |
| Example | http://www.wikimama.com |
|
Check usage (experimental) |
|
AdsWherever is a very simple extension that displays any advertising codes on your wiki page.
Contents |
[edit] Source
Copy the following code into extensions/AdsWherever.php:
<?php $wgExtensionCredits['parserhook'][] = array( 'name' => 'AdsWherever', 'description' => 'Place any ads wherever you want', 'author' => 'Wikimama', 'url' => 'http://www.wikimama.com' ); $wgHooks['ParserFirstCallInit'][] = 'AdsSetup'; function AdsSetup( &$parser ) { $parser->setHook( 'ads', 'AdsRender' ); return true; } function AdsRender($input, $args ) { $input =""; $url = array(); // Google Adsense Example $ad['goo1'] = '<div class="thumbnail"><div id="ads">'."\n"; $ad['goo1'] .= '<script type="text/javascript"><!--'."\n"; $ad['goo1'] .= 'google_ad_client = "Your Publisher ID";'."\n"; $ad['goo1'] .= 'google_ad_slot = "The Ads slot number";'."\n"; $ad['goo1'] .='google_ad_width = ;'."\n"; $ad['goo1'] .= 'google_ad_height = ;'."\n"; $ad['goo1'] .= '//-->'."\n"; $ad['goo1'] .= '</script>'."\n"; $ad['goo1'] .= '<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">'."\n"; $ad['goo1'] .= '</script>'."\n"; $ad['goo1'] .= '</div></div>'; // Commission Junction Example $ad['code1'] = '<a href="http://www.example.com/123" target="_blank">'; $ad['code1'] .= '<img src="http://www.example.com/123.gif" width="190" height="190" /></a>'; // Commission Junction Example $ad['example'] = '<a href="http://www.google.com">'; $ad['example'] .= 'Hello world</a>'; $media = $args['media']; return $ad[$media]; }
[edit] Installation
- Create the file AdsWherever.php and paste the code shown above. Make sure there are no empty lines after the final php exit tag.
- Upload adswherever.php to your $IP/extensions directory.
- Add the following lines at the end of LocalSettings.php:
require_once("extensions/AdsWherever.php");
[edit] Usage
After you set the variable in $ad['name'], insert a tag into anywhere of your page. Here is an example to insert the google adsense code.
To insert this tag:
<ads media=Goo1>
It will show the whole google adsense code.
Also try
<ads media=example />
where it shows the Hello World example as above.