Personal tools
Writing
Other Stuff

Setting up your wiki

From Wikiexpert

Jump to: navigation, search

Here are some basic "best practice" guidelines for setting up MediaWiki. If you buy my Bells and whistles package, this all happens for you!


Contents

Beautifying URLs

pretty URL's:

Before
http://www.example.com/wiki/index.php/Article_Name
After
http://www.example.com/Article_Name
Howto

In the ROOT directory of www.example.com place the following .htaccess file:

RewriteEngine on
# do the rewrite
RewriteRule ^wiki/?(.*)$ /w/index.php?title=$1 [L,QSA]

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. The following solution will cause ads to not be displayed on Special, User, User talk, Image, Template, and edit/preview pages.

You can limit 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:


               echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
               ?>">
               <?php $this->msg($special) ?></a></li><?php } ?>
             <?php } ?>
           </ul>
         </div>
       </div>


put this:

       <?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:

<php if($this->data['catlinks']) { ?>
<?php    } ?>

put this:

           <?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:

 <div id="p-advertisement" class="portlet">
 <h5>Advertisement</h5>
 <div class="pBody">
  Paste Google code here
 </div>
 </div>


adsense_horizontal.php:

 <div style="border: 1px solid #ccc; padding: 1px; margin-top: 25px;">
  Paste Google code here
 </div>

I've found that these layouts fit nicely with the Monobook skin. For the vertical ad, the 120x240 tall format ad works best.

Google Analytics

For those using Google Analytics (http://www.google.com/analytics/) (now free and openly available), here is the short and simple way to modify your code to be recognized by Google's site tracker:

In the MonoBook.php file (or your skin file of choice), insert the following code right before the "</body>" tag (no quotes):

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
 <script type="text/javascript">
 _uacct = "UA-XXXXXX-1";
 urchinTracker();
 </script>

Where you would replace the "XXXXXX" with the tracker number associated with your Analytics account.

Google Maps

To add google maps to your wiki, install the Google Maps Extension


Credits: http://webhostingreal.com/content/view/14/1/