![]() Release status: stable |
|
---|---|
Implementation | Skin | , MyWiki , Hook
Description | Ads banners defined in LocalSettings.php |
Author(s) | WikiMANNia (WikiForMentalk) |
Latest version | 2.2.0/ 3.0.0a (2023-01-01) |
MediaWiki | 1.23-1.39 |
PHP | 5.6+ |
License | GNU General Public License 2.0 or later |
Download | GitHub: Note: |
Example | http://39.wikimannia.org |
Parameters
|
|
Hooks used
|
|
The WimaAdvertising extension offers four additional advertising
blocks to the Cologne Blue , Modern , MonoBook , Timeless , and Vector skin. The banners are placed in the top and bottom of the wiki and two of them in the sidebar .Use
One ad block is located at the top of the "MediaWiki:Sitenotice", a second one below the article text in front of the category bar and two more ad blocks in the sidebar.
By entering * AD1
and * AD2
in the MediaWiki:Sidebar, these can be placed individually.
If Sitenotice is defined, the TopBanner will be displayed randomly alternating with the Sitenotice message.
Installation
- Download and place the file(s) in a directory called
WimaAdvertising
in yourextensions/
folder. - Add the following code at the bottom of your LocalSettings.php
wfLoadExtension( 'WimaAdvertising' );
file: Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
To users running MediaWiki 1.24 or earlier:
The instructions above describe the new way of installing this extension using wfLoadExtension()
.
If you need to install this extension on these earlier versions (MediaWiki 1.24 and earlier), instead of wfLoadExtension( 'WimaAdvertising' );
, you need to use:
require_once "$IP/extensions/WimaAdvertising/WimaAdvertising.php";
Configuration options
Enable advertising. Default is false
.
$wgWimaAdvertising = true;
Disable advertising for logged-in users. Default is false
.
$wgWimaAdvertisingAnonOnly = true;
wgBannerType
- Set the type of the banner
- Possible values: 'advertising', 'eventnote', 'hint'
- Default value: 'advertising'
$wgBannerTopType = "eventnote";
$wgBannerBottomType = "eventnote";
$wgSidebarAd1Type = "advertising";
$wgSidebarAd2Type = "hint";
wgBannerCode
- Set a html snippet of the banner.
$wgBannerTopCode = '<a title="Uhren-Wiki" href="https://www.uhren-wiki.net"><img src="https://wikimannia.org/skins/werbung/Werbung - Oben.jpg" width="728" height="92" alt="Werbung" /></a>';
$wgBannerBottomCode = '
Your banner code here.
';
$wgSidebarAd1Code = '<a title="Schwarzbuch Wikipedia" href="https://de.wikimannia.org/Schwarzbuch_Wikipedia"><img src="https://wikimannia.org/werbung/images/130px-Schwarzbuch_Wikipedia.jpg" alt="Schwarzbuch_Wikipedia.jpg" /></a> <p><b>Schwarzbuch Wikipedia</b></p><p class="small">Mobbing, Diffamierung und Falschinformation in der Online-Enzyklopädie, und was jetzt dagegen getan werden muss.</p><p>Im Februar 2020 im <i>Zeitgeist-Verlag</i> erschienen.</p>';
$wgSidebarAd2Code = 'Your banner code here.';
You can also do Google AdSense:
$wgSidebarAd2Code = '<script type="text/javascript"><!--
google_ad_client = "pub-9471398824076666";
/* ID 007 */
google_ad_slot = "3512091103";
google_ad_width = 145;
google_ad_height = 260;
google_language = "en";
google_encoding = "utf8";
// -->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
wgBannerStyle
- Set the CSS style specifications for the banner.
$wgBannerTopStyle = 'text-align:center;border:1px solid blue;';
$wgBannerBottomStyle = 'text-align:center;border:1px dotted red;';
Google Adsense
Enable advertising. Default is false
.
$wgWimaGoogleAdSense = true;
Disable advertising for logged-in users. Default is false
.
$wgWimaGoogleAdSenseAnonOnly = true;
Mandatory parameters
// Replace this with your own publisher ID (google_ad_client / data-ad-client)
$wgWimaGoogleAdSenseClient = 'none'; // Client ID for your AdSense script (example: ca-pub-1234546403419693)
(You can get your publisher ID and ad unit ID from the "Get code" page: Get and copy the ad code.)
Ad units
Define up to four ad units:
$wgWimaGoogleAdSense_AD1= [ 'slotid 1', 145, 260 ];
$wgWimaGoogleAdSense_AD2= [ 'slotid 2', 145, 260 ];
$wgWimaGoogleAdSense_Top= [ 'slotid 3', 145, 260 ];
$wgWimaGoogleAdSense_Bottom = [ 'slotid 4', 145, 260 ];
Replace the first value with your AdSense ad unit ID (google_ad_slot / data-ad-slot) for each ad unit. The Slot ID for your AdSense script is for example 1234580893.
Also specify the width and the height of the AdSense unit, specified in your AdSense account (google_ad_width / data-ad-width, google_ad_height / data-ad-height).
Optional parameters
Add any of the optional settings below – if your settings deviate from the defaults:
// This can be anything you like. Default is 'none'.
$wgWimaGoogleAdSenseID = 'none';
// Source URL of the AdSense script. No need to change - it can't deviate from the defaults.
$wgWimaGoogleAdSenseSrc = '//pagead2.googlesyndication.com/pagead/show_ads.js';
// Text coding. Default is 'utf8'.
$wgWimaGoogleAdSenseEncoding = "utf8";
// Advertising language. Default is $wgLanguageCode.
$wgWimaGoogleAdSenseLanguage = "en";
Hacks
Skin Vector
Skin Vector in revision 1.35 and 1.36 needs a hack to make the extension work for the ads in the sidebar.
In file includes/VectorTemplate.php
change line 450 (REL1_35), respectively in file includes/SkinVector.php
change line 337 (REL1_36):
$props['class'] = trim( "$class $extraClasses[$type]" );
into:
$props['class'] = trim( "$extraClasses[$type]" );
Skin MonoBook
For the Skin MonoBook, the ad at the bottom might look better if the hook is moved to the end of the content area.
In file includes/MonoBookTemplate.php
change lines 85-91:
'<!-- end content -->' .
$this->getClear()
)
);
$html .= $this->deprecatedHookHack( 'MonoBookAfterContent' );
$html .= $this->getIfExists( 'dataAfterContent' ) . $this->getClear();
$html .= Html::closeElement( 'div' );
into:
'<!-- end content -->' .
$this->getClear() .
$this->getIfExists( 'dataAfterContent' ) .
$this->getClear()
)
);
$html .= Html::closeElement( 'div' );
In file templates/skin.mustache
change lines 20-24:
<!-- end content -->
<div class="visualClear"></div>
</div>
</div>{{{html-after-content}}}
<div class="visualClear"></div>
into:
<!-- end content -->
<div class="visualClear"></div>
</div>{{{html-after-content}}}
</div>
<div class="visualClear"></div>
See also
- PCR GUI Inserts did something similar since REL 1.23, but not as sophisticated.
- Google AdSense does the same, but only for one banner. And it does not allow custom banners.
Remarks
- This extension works from REL1_25 and has been tested up to MediaWiki version 1.39.1.
- The SkinBuildSidebar hook no longer allows images for several Skins and HTML code to be placed in the sidebar.
- So only the upper and lower add slots are still available.
- A solution for this circumstance is not yet known.
- Version 2.1 has added support for Skin
vector-2022
. - Version 2.2 has added support for Skin
Timeless
.
Version 3.0
- The version 3.0 has a new approach, with click-away ads that are fixed and do not disappear when scrolling, and are (largely) independent of the skin. (See first impression)
- At the moment only tested with MediaWiki version
1.39.1
. - Download on GitHub (alpha Version)