Current time: 04-24-2014, 11:12 PM Hello There, Guest! (LoginRegister)

Post Reply 
MediaWiki and Google AdSense
08-27-2005, 12:22 PM
Post: #1
MediaWiki and Google AdSense
If you're interested in running a MediaWiki site with Google AdSense, you should know that in order to comply with the Google TOS, you shouldn't display ads on non-content pages.

I've solved this by limiting my users' choice of skins to Monobook, and modifying the Monobook.php file as follows:

For a vertical ad below your left-side navigation, after this:
Code:
echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
?>"><?php $this->msg($special) ?></a></li><?php } ?>
<?php } ?>
</ul>
</div>
</div>
put this:
Code:
<?php
if(!strstr($_SERVER['REQUEST_URI'], "Special:") &&
!strstr($_SERVER['REQUEST_URI'], "User:") &&
!strstr($_SERVER['REQUEST_URI'], "User_talk:") &&
!strstr($_SERVER['REQUEST_URI'], "Image:") &&
!strstr($_SERVER['REQUEST_URI'], "action=submit") &&
!strstr($_SERVER['REQUEST_URI'], "action=edit") &&
!strstr($_SERVER['REQUEST_URI'], "Template:")) {
include("adsense/adsense_vertical.php");
}
?>
For a horizontal ad at the bottom of your articles, after this:
Code:
<?php if($this->data['catlinks']) { ?><div id="catlinks"><?php $this->html('catlinks') ?></div><?php } ?>
<!-- end content -->
<div class="visualClear"></div>
put this:
Code:
<?php
if(!strstr($_SERVER['REQUEST_URI'], "Special:") &&
!strstr($_SERVER['REQUEST_URI'], "User:") &&
!strstr($_SERVER['REQUEST_URI'], "User_talk:") &&
!strstr($_SERVER['REQUEST_URI'], "Image:") &&
!strstr($_SERVER['REQUEST_URI'], "action=submit") &&
!strstr($_SERVER['REQUEST_URI'], "action=edit") &&
!strstr($_SERVER['REQUEST_URI'], "Template:")) {
include("adsense/adsense_horizontal.php");
}
?>
Now, you'll need to create an adsense/ directory in your main wiki directory, and place two files in it, adsense_horizontal.php and adsense_vertical.php as needed.

The contents of my files are as follows:

adsense_vertical.php:
Code:
<div id="p-advertisement" class="portlet">
<h5>Advertisement</h5>
<div class="pBody">
[b]Paste Google code here[/b]
</div>
</div>
adsense_horizontal.php:
Code:
<div style="border: 1px solid #ccc; padding: 1px; margin-top: 25px;">
[b]Paste Google code here[/b]
</div>
I've found that these layouts fit nicely with the Monobook skin. For the vertical ad, the 120x240 tall format ad works best.
Find all posts by this user
Quote this message in a reply
08-27-2005, 09:27 PM
Post: #2
MediaWiki and Google AdSense
Thanks for the tip.

--
Alec Usticke
alec@usticke.org
www.usticke.org
DreamHost referral
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: