Reputation: 21
I'm trying to add a custom sidebar for each page as asked also in this question: Different sidebar for mediawiki pages. Following the answer I've created two pages ( Sidebar1 and Sidebar2 ) and then in MediaWiki:Sidebar I've used the ParserFunctions in order to specify the correct page to include in this way:
{{#ifeq: {{PAGENAME}} | Main_Page | {{:Sidebar1}} |
{{#ifeq: {{PAGENAME}} | Other_page | {{:Sidebar2}} | {{:Sidebar_generic}} }}
}}
However this solution seems that doesn't works.
I've also tried to include the extension https://www.mediawiki.org/wiki/Extension:CustomSidebar, but with no success.
Anybody can point me the right way to do this?
I'm using mediawiki 1.28.0-rc.0 with the following skin: https://www.mediawiki.org/wiki/Skin:Bswiki.
Upvotes: 2
Views: 260
Reputation: 11
Finally I've resolved in this way:
function testSidebar( $skin, &$bar ) {
global $wgTitle;
if (strcmp($wgTitle,"TestPage1") == 0 ) {
$bar = array();
$skin->addToSidebar($bar,'MySidebar');
}
return true;
}
Upvotes: 1
Reputation: 21
I've somehow manage to do this following the code of the plugin "hideSideBar" by inserting an hook to SkinBuildSidebar:
$wgHooks['SkinBuildSidebar'][] = 'testSidebar';
function testSidebar( $skin, &$bar ) {
global $wgUser;
// Hide sidebar for anonymous users
if (!$wgUser->isLoggedIn()) {
$url = Title::makeTitle(NS_SPECIAL, 'UserLogin')->getLocalUrl();
$bar = array(
'navigation' => array(
array('text' => wfMessage( 'MySidebar' )->inContentLanguage()->plain(),
)
)
);
}
return true;
I've created the page MediaWiki:MySidebar, and for the anonymous user the content inside that page is displayed correctly as sidebar, BUT not formatted. Example: in Mediawiki:MySidebar I have:
* Entry1
** Entry2
But in this way I see an entry in the sidebar with the raw text * Entry1 ** Entry2 and not a correctly formatted sidebar as the currently in use skin usually does.
How can I resolve this issue?
Upvotes: 0