Update (2011-07-17): the easiest way, rather than modifying the source code, is to use the PCR GUI Inserts MediaWiki extension.
Here is how we set up Google Adsense (and more generally, a customized ad area which will show Google Adsense on pages where it is allowed, and another ad on other pages) to show in MediaWiki 1.14.0:
1. Force the monobook skin for everyone (unless you want to edit every skin…) by putting this setting in LocalSettings.php:
$wgAllowUserSkin = false;
NB: this setting is new to MediaWiki 1.14! If you have an older version, either upgrade or see our previous tutorial
2. In your skins folder, create a file within a subfolder (for instance “0custom/ad_vertical.php”) with the following content (edit with your own Google Adsense code as well as your own alternative ad; also, make sure to choose a VERTICAL ad, since we are adding code in the left sidebar!):
<?php
if(!strstr($_SERVER['REQUEST_URI'], "Special:") &&
!strstr($_SERVER['REQUEST_URI'], "action=submit") &&
!strstr($_SERVER['REQUEST_URI'], "action=edit") &&
!strstr($_SERVER['REQUEST_URI'], "Template:"))
echo '<div id="v-g-ads" class="portlet">
<h5>Google ads</h5>
<div class="pBody">
<script type="text/javascript"><!--
google_ad_client = "pub-9471398824076666";
/* 120x240 for Wiki4Games sidebar */
google_ad_slot = "3512091103";
google_ad_width = 120;
google_ad_height = 240;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</div>';
else echo '<div id="v-g-ads" class="portlet">
<h5>Ads</h5>
<div class="pBody">
<a href="http://proxify.com/r/?s=1320"><img src="http://proxify.com/i/info-110x110.gif" width="110" height="110" alt="disable proxy" border="0"></a>
</div>
</div>';
?>
3. Edit MonoBook.php as follow:
Replace:
function languageBox() {
if( $this->data['language_urls'] ) {
?>
<div id="p-lang" class="portlet">
<h5><?php $this->msg('otherlanguages') ?></h5>
<div class="pBody">
<ul>
<?php foreach($this->data['language_urls'] as $langlink) { ?>
<li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
<?php } ?>
</ul>
</div>
</div>
<?php
}
}
With:
function languageBox() {
if( $this->data['language_urls'] ) {
?>
<div id="p-lang" class="portlet">
<h5><?php $this->msg('otherlanguages') ?></h5>
<div class="pBody">
<ul>
<?php foreach($this->data['language_urls'] as $langlink) { ?>
<li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
<?php } ?>
</ul>
</div>
</div>
<?php
}
include("0custom/ad_vertical.php");
}
NB: In fact we’re just adding the include at the end of the function.
4. Upload the stuff (don’t forget there are 2 files to upload, not just one), and you’re done 🙂
i am a beginner in monetizing my blog with Adsense. i still need to learn more about the tips and tricks on Adsense. hopefully i might be able to earn a decent amount of cash on Adsense.
i really love Google Adsense. i could earn a decent amount of cash with this make money online program from Google.
Adsense is the best paying make money online program on the internet. I just wish that i could increase my website traffic to high levels so that i could earn more money on Adsense.
i use Adsense on my blogs and websites, i can say that Adsense is the best make money online program on the internet.
If you spammers don’t get more insightful you’ll never manage to get your Viagra links published along with your comment…
i love Google Adsense, it allows me to make money on my personal blog and some of my health related sites.
Hi. I’m gonna give this a whirl right now. I’m using mediawiki 1.17 and I’ve been looking for and adsense solution. Hopefully this is it!
-TJ