Wednesday 11 November 2009

MediaWiki - Add a tab to everyone's Personal Tools

For a while now, I had adding an extra option to the Personal Tools on my list of things to do. My wiki's main entry point for my users is through my forum (which has a user-bridge to the wiki, meaning it is not neccessary for my users to create seperate logins for the wiki if they already have an account on the forum), but I wanted to add a link back to the main site somewhere.

The logo would have been my choice, but we use that for users to be able to return back to the main wiki-site. So I figured it would be nice to add this to the "Personal Tools" menu, which is the menu in the upper right corner that shows your username, "My talk", "My preferences", etc.

Here's how to do it. In your includes folder, there's a file called SkinTemplate.php. Open that in an editor, and look for the following:

[code]
$personal_urls['userpage'] = array(
'text' => $this->username,
'href' => &$this->userpageUrlDetails['href'],
'class' => $this->userpageUrlDetails['exists']?false:'new',
'active' => ( $this->userpageUrlDetails['href'] == $pageurl )
);[/code]

Directly above that, add the following:

[code]
$personal_urls['myId'] = array(
'text' => 'myText',
'href' => 'myHref'
);[/code]

myId is a unique identifier name for the personal url.
myText is the name you want the link to have
myHref is where the new link should point to.

That's it. You're done.

Note that the method above means the link will be the first link to appear. If you prefer setitng it somewhere inbetween instead, move the snippet of code to the proper location.

No comments: