User:Egingell
From MediaWiki.org
Contents |
[edit] Egingell's Hacks
[edit] Custom Sidebar per Namespace
[edit] Replace (global declaration) Line ~1589 in includes/Skin.php
[edit] Original
global $wgLang, $wgContLang;
[edit] New
global $wgLang, $wgContLang, $wgTitle;
[edit] Replace (sidebar definition) Line ~1609 in includes/Skin.php
[edit] Original
$lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
[edit] New
[edit] alternate 1
// Change the default sidebar to a custom one (MediaWiki:Sidebar_[NS_NUM] if it exists) on any namespace,
// not just custom namespaces. If MediaWiki:Sidebar_[NS_NUM] doesn't exists, use MediaWiki:Sidebar.
$sideBar_str = wfMsgForContent( 'sidebar_'.$NameSpaceNumber );
if ($sideBar_str != '<sidebar_'.$NameSpaceNumber . '>' ) {
$lines = explode( "\n", $sideBar_str );
} else {
$lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
}
[edit] alternate 2
// Change the default sidebar to include a custom one (MediaWiki:Sidebar_[NS_NUM] if it exists)
// on any namespace, not just custom namespaces.
$sideBar_str_default = wfMsgForContent( 'sidebar' );
$sideBar_str_custom = wfMsgForContent( 'sidebar_'.$NameSpaceNumber );
if ($sideBar_str_custom != '<sidebar_'.$NameSpaceNumber.'>' ) {
$sideBar_str_default .= "\n" . $sideBar_str_custom;
}
// Remove dupes. See array_unique()
$lines = array_unique(explode( "\n", $sideBar_str_default ));
[edit] Info
MediaWiki:Sidebar => Default Sidebar
MediaWiki:Sidebar_[NS_NUM] => Custom Sidebar for [NS_NUM]
[edit] Note
You can get the namespace number from Special:Prefixindex. Look at the URL in the Location/Address bar of your web browser, it will look like this:
[Your Wiki Site]/index.php?title=Special%3APrefixindex&from=&namespace=[NS_NUM]