Manual:Interface/Sidebar

MediaWiki:Sidebar defines the navigation bar, which provides links to the most important locations in the wiki and supplies site administrators with a place to add a persistent collection of links. For instance, most wikis will link to their community discussion page and some useful tools.

The default Monobook skin places the navigation bar on the top-left (top-right for right-to-left languages) along with the search bar and toolbox, but the placement may be different in other skins.

Customizing the sidebar
As an administrator, edit the wiki page "MediaWiki:Sidebar". (The editinterface permission needs to be enabled and is enabled for administrators by default; for information on assigning it to other groups, see Manual:User rights.)

Example sidebar code:
 * navigation
 * mainpage|mainpage
 * Special:Recentchanges|Recent changes
 * new heading
 * portal-url|portal
 * http://www.mediawiki.org|MediaWiki home

Headings
The navigation bar can be split into sections, each with a heading of its own. The heading for each section is taken from the first-level list element ("navigation" and "new heading" in the example above).

If this text corresponds to the name of an interface message (an existing page of that title in the MediaWiki namespace), then the text of that page is used as a label; otherwise, the header title is used as-is.

Bug: only the first section will be shown in the Classic, Cologne Blue, and Simple skins (bug 2557).

Bug: no sidebar is shown in the Nostalgia skin (bug 10794).

Links
Second-level list elements are links ("mainpage|mainpage" in the example above), where the format is: ** target|link text

Target
The link target can be the name of an interface message (page in the MediaWiki namespace) or wiki page, or an external link. If the target is the name of an existing or default interface message, the content of that message will be used. Otherwise, the target is used as-is.

In either case, the link can be internal, interwiki, or external. In some cases (such as links with the "&" character), an interface message is necessary.

Examples:
 * " " uses the text of MediaWiki:Portal-url (which contains "").
 * " " links to Special:Recentchanges, since there is no interface message of that name.
 * " " links to Foo for the same reason.
 * " " links to http://www.mediawiki.org for the same reason.

The link target cannot be made dependent on the interface language set in the preferences.

Text
The link text can be the name of an interface message (page in the MediaWiki namespace) or plain text.
 * If the link text is the name of an existing or default interface message, the content of that message will be used. MediaWiki will check for localized versions; for example, if the current language is fr (French) and the link target is the interface message "forum-url", it will check for "forum-url/fr" before using "forum-url".
 * Otherwise, the link text is used as the target as-is.
 * Notice that the link text is not optional as in normal wiki links. If the link text is missing, the item is ignored.

Examples:
 * uses MediaWiki:Mainpage (which contains "").
 * uses "Recent changes", since there is no interface message of that name.

content of sidebar and toolbox (javascript)
The toolbox which appears under the search bar, is a dynamic element and cannot be easily customized without the use of skinning extensions (otherwise it requires programming in PHP.) If you still want to do so, you can copy skins/MonoBook.php, creating a new skin. You can then make a custom skin to generate these links in your preferred fashion.

Another javascript solution is below.

For this solution to work on the entire mediawiki site, this script has to be copied to MediaWiki:Common.js (MediaWiki:Common.js is available for Mediawiki 1.9 +).

For this solution to work only for a specific user, add this script to Special:Mypage/monobook.js (or another js-page, depending on your prefered skin).

Now simply configure which link should appear in which section. You also can remove some links if you want to.

usage
function CustomizeModificationsOfSidebar has to be customized for adding or removing links in specific sections:

ModifySidebar("action", "section", "name", "link");

restricting modifications to specific usergroups
If you want to restrict the modification of the links to a specific usergroup (e.g. bureaucrat), change

to and add

For restricting the modifications to IPs instead of a specific usergroup use

Sidebar width (monobook specific)
You can change the width of your sidebar by adding the following CSS rules to your MediaWiki:Common.css article (MediaWiki:Monobook.css if pre 1.9), note that this is an article not a file. This changes the width to 15em, the actions position and portlet width should be an em or so less, so I've set them to 14em in this example.

different sidebars for logged in users and anonymous users (php)
To get anonymous users to have their own sidebars change includes/Skin.php. There is a function called buildSidebar. Edit this function to check for $wgUser->isLoggedIn and call a different system message than sidebar.



Then in your Wiki, go to MediaWiki:anon_sidebar and create your new sidebar. You may need to add $wgUser to the list of global variables in the buildSidebar</tt>.

Changes not showing up
MediaWiki aggressively caches content if possible, which often causes the navigation bar to persist after changes. Purging the cache of affected pages should correct the situation. To perform a mass-purge of all caches at once, touch the LocalSettings.php</tt> file or truncate the objectcache</tt> table in your database (you may have to do both).

You also need to have $wgUseDatabaseMessages set to true</tt>.

Lowercase link labels
If your links are not being capitalized as intended, try adding spaces around the bar character; for example: ** http://www.example.com/download.php?file=44555 | Download

Sections disappear or show unexpected content
If a section does not display or displays unexpected content, check that the header text isn't the name of an interface message by searching Special:Allmessages. If it is, use a different header text, or create a new interface message and use it.

For example, if you want to use "Sidebar" as header text, create the interface message "MediaWiki:Sidebar-header" containing only "Sidebar". Then, use  as header.

Broken links after updating Special:Version
This will happen e.g., each time there are newer translations for your site language's sidebar items. One could add new redirect pages each time, but a better solution would be to use one's own sidebar item names instead of trying to keep track of the current MediaWiki translations.

Wikitext in side bar
Many people on support desk have been asking about how to put arbitrary wikitext into the side bar. You can hack your skins/Monobook.php file (if you're using monobook) and replace the following section of code... with this... That will allow the MediaWiki:Sidebar article to be proper wikitext. You will need to include the 'pBody' div tag to ensure the portlet is styled correctly, so your MediaWiki:Sidebar article will need to look something like the following example after the change: Navigation
 * Main Page
 * Community portal
 * [ Recent changes]
 * Sandbox
 * Help