Adding Custom Tabs to MediaWiki

I just hacked out my first piece of custom MediaWiki interface: adding custom tabs next to the standard “Article,” “Edit,” “Discussion,” etc. tabs. I was surprised that there was no existing documentation on how to do this. So I decided to write my own for the benefit of other amatuers like me. Here’s how you can do it:

1) Before starting, you have to be working from a skin that is built on SkinTemplate.php. If you aren’t sure, then you probably are. (I’m sure there are ways to add custom tabs to other skins, but I don’t know how.)

2) Create a new custom namespace. This is what will come before the colon in the new page’s address, eg “yourdomain.com/wiki/NewNamespace:Pagename”. (NOTE, 5/15/2008: The instructions for this step are based on an old version of MediaWiki (1.7). Rich points out in Comments that for versions back to at least 1.12, you should follow the official instructions here.)

To do this, open the LocalSettings.php file in your wiki’s directory. Around Line 150 or so, you’ll see some code like this:

$wgNamespacesWithSubpages = array(
NS_TALK           => true,
NS_USER           => true,

Right above that, add the line

$wgExtraNamespaces = array(100 => "New_namespace");

replacing New_namespace with your own custom name.… Read the rest