Your use of the information on Hobbs Knowledge Base is at your own risk and I accept no responsibility for any damage caused. More info here.
How to Get Google AdSense Adverts Onto Your Wiki
From Hobbs Knowledge Base
How To Display AdSense Adverts Within Articles
In order to display Google AdSense adverts within articles on your wiki you need to install the MyScript extension.
View source of the Template:Adsense_468x60 to see how the Template was made. This is then included in the site by typing the following, of course:
{{Adsense_468x60}}
Here's an example:
How To Display AdSense Adverts At The Bottom Of Your Site
In order to display Google AdSense adverts at the bottom of every page on your wiki, you need to use one of several methods. The method i used was to simply edit the default "Monobook" skin, so that is what I shall document here.
WARNING: By doing this method, you will have to re-apply any changes you make every time you upgrade your Wiki, because you will be editing the main skin for the site!
First of all, create the file "/advertising/adsense.php" and put exactly what Google Adsense gives you into it. Nothing more, nothing less.
This file should look something like this:
<script type="text/javascript"><!-- google_ad_client = "pub-83477868273648837"; google_ad_slot = "7238762387"; google_ad_width = 468; google_ad_height = 60; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
Once this is done, open up "/wiki/skins/MonoBook.php" and add the lines in red below:
<?php } ?>
</div><!-- end of the left (by default at least) column -->
<div class="visualClear"></div>
<!-- BEGIN GOOGLE ADSENSE -->
<?php
global $wgTitle;
$ns = $wgTitle->getNamespace();
if($ns==0) {
?>
<div align="center">
<?php include("../advertising/adsense.php"); ?>
</div>
<?php } ?>
<!-- END GOOGLE ADSENSE -->
<div id="footer">
<?php
if($this->data['poweredbyico']) { ?>
<div id="f-poweredbyico"><?php $this->html('poweredbyico') ?></div>
<?php }
if($this->data['copyrightico']) { ?>
NOTE: You'll notice that the code snippet above contains the following line:
if($ns==0) {
This line specifies that the include() will only be run (and the adverts therefore displayed) when the Namespace ("$ns") equals 0.
"Which Namespace is 0?" I hear you ask. Well, it's the main Namespace (i.e. standard articles).
You can run the include() (and therefore display the adverts) on a more than one Namespace by increasing the if() statement to include other Namespace IDs:
if($ns==0 || $ns==12) { // this would display the adverts on Help pages too.
"How do I find out which IDs equal which Namespaces?" i now hear you ask. Well, this can be found in "/includes/Defines.php". I have also copied the relevant section from my copy of that file here:
define('NS_MAIN', 0);
define('NS_TALK', 1);
define('NS_USER', 2);
define('NS_USER_TALK', 3);
define('NS_PROJECT', 4);
define('NS_PROJECT_TALK', 5);
define('NS_IMAGE', 6);
define('NS_IMAGE_TALK', 7);
define('NS_MEDIAWIKI', 8);
define('NS_MEDIAWIKI_TALK', 9);
define('NS_TEMPLATE', 10);
define('NS_TEMPLATE_TALK', 11);
define('NS_HELP', 12);
define('NS_HELP_TALK', 13);
define('NS_CATEGORY', 14);
define('NS_CATEGORY_TALK', 15);
WARNING: There is one clause in the non-South Korea Google Adsense Terms and Conditions (as of 29 January 2008) that states:
- 5. Prohibited Uses. You shall not, and shall not authorize or encourage any third party to: ..... (v) display any Ad(s), Link(s), or Referral Button(s) on any error page, on any registration or "thank you" page (e.g., a page that thanks a user after he/she has registered with the applicable Web site), on any chat page, in any email, or on any Web page or any Web site that contains any pornographic, hate-related, violent, or illegal content;
There is also a line in the Google AdSense Program Policies (as of 29 January 2008) that states:
- Ad Placement
- No Google ad may be placed on any non-content-based pages.
So, as a result of these clauses, you should obviously be careful as to which pages you put the adverts on!
| If the information on this page is either out-of-date, incorrect, or if you'd just like more information then please Contact Me. |

