Extension talk:CustomSidebar

Comments & bug reports welcome :) --Frantik 08:46, 28 May 2009 (UTC)

TOC in sidebar
Why doesn't work? Trying to put a Table of Contents in the sidebar. --two7s_clash


 * well even if it replaces correctly, which i doubt, the text wouldn't be in the proper format --Frantik 08:38, 17 April 2010 (UTC)


 * is there a way to do such a thing using your extension? get the TOC to render in the sidebar? --two7s_clash
 * not at this time --Frantik 19:54, 17 April 2010 (UTC)

not transcluded from templates
I'm trying to add a custom sidebar through a template. I've put a custom sidebar (using the tag) in a template. However, when I include the template in a page, the custom sidebar doesn't show on that page; instead the sidebar shows up on the template page. This happens even though the tags appear between tags.

Any ideas for a fix or workaround? I'm no Wiki expert, but I'm guessing it has something to do with searching for tag in wgArticle->getContent without parsing it first? ~KH


 * Fixed my own problem! Preprocessing the article text solves this issue. I've managed this by initiating a parser (+ parseroptions) and replacing $pagetext = $wgArticle->getContent; with $pagetext = $wgParser->preprocess( $wgArticle->getContent, $wgArticle->getTitle, $opt ); Please add this fix or a similar solution in the next revision of this extension. ~KH
 * Cool thanks :) I've been meaning to release a newly updated version with many new features; I will include your changes as well. --Frantik 09:44, 7 August 2009 (UTC)
 * I was able to use your suggestion to enable full template support, so thanks :) version 0.3.0 is available for download now --Frantik 22:34, 9 August 2009 (UTC)

Adding a second bar?
Thank you for the good extension. I wonder if it would be possible to add another function to call within the skin php file, as we do with the buildsidebar built in function? I mean a "build_top_bar" function that works as your extended sidebar. Can you implement this? Generating a second bar different to manage via your extension would be really nice for me (though it has to be customized in the skin).--Federicodip 20:14, 8 August 2009 (UTC)
 * I'm not quite sure I understand what you mean --Frantik 10:58, 9 August 2009 (UTC)
 * It was late night and I realize now what I wrote was cryptic. I'll try to explain my project:
 * I wanted to create a second bar (topbar) that I wanted to manage like the default sidebar, editing a page wihin mediawiki (mediawiki:sidebar). This was the beginning. When I saw your extension I realized that the bar could have some dynamical content. And in the example:  $wgDefaultSideBarText = ':/Sidebar'  - I saw it could be possible to customize bars content for different namespaces.
 * In your extension you use a hook to change the default buildSidebar function. I don't know much about building an extension, but I thought about changing a bit of your code, using part of your extension (mostly the function fnSidebarHook) without the hook, not to change buildSidebar, but to provide a new function buildTopbar that I could call wihin my skin file. So I could use and manage a second navigation bar, dynamically based on namespaces.
 * I also thought about changing the code so that I could manage namespaces bar content using only a single page mediawiki:top(ns)bar in witch rows with a * at the beginning define namespaces, and rows with two ** at the beginning are links of that namespace, but as a php noob its not so easy for me. Anyway a $wgDefaultTopBarText would work good and I could customize many foo/(top)bar. Can you help me? Can I try to change your extension and to build a new one using your code?--Federicodip 12:05, 9 August 2009 (UTC)
 * I'm not sure if you can use my extension because Mediawiki generates the HTML for the sidebar after the hook is run.. so you can't just include the function in the skin --Frantik 21:16, 9 August 2009 (UTC)
 * I've seen you added "... an additional sidebar" in your 3.0 release. :D
 * Can you explain a bit more how it works? I mean, does it add data to sidebar or provides a brand new one? And how must I call that bar in my skin? Something like that works?:
 * data['new_bar'] as $bar => $cont) { ?>
 * You do not add anything to your skin. The extra sidebars still appear in the sidebar region of your skin.  The extra features just allow you to customize sidebars based on namespace and usergroup.  instead of replacing the other sidebar text, it appends it.  My extension does not access the skin layer at all, it just processes text and converts it into the format that mediawiki expects for sidebars.  --Frantik 14:00, 10 August 2009 (UTC)

CSS for Custom Sidebar?
I have created a skin with much CSS on my wiki site. I have now included this extension CustomSidebar, but I can't find out what ID or class I can use for CSS for the generated sidebar. The custom sidebar is in this div:. I have tried using both this class and id in my main.css, but the custom sidebar will not use the CSS. My MediaWiki version is 1.15.1. I would very much appreciate any advice on what to do to be able to use CSS on the custom sidebar. Thank you. HelenaH 09:30, 20 November 2010 (UTC)
 * Custom sidebar does not use any custom CSS or any HTML at all, so i'm not sure exactly what your problem is or how to solve it --Frantik 00:57, 21 November 2010 (UTC)
 * The CSS I use is for portlet IDs like #p-navigation and #p-tb, and all my CSS is in a separate style-sheet (a .css-file). When I installed Custom sidebar the additional (custom or generated) portlet did not look like the standard portlets. For example, I did not use bullets for the lists in p-navigation and p-tb, but the generated sidebar did have bullets. So in my sidebar I had first the default navigation-portlet without bullets, then the customsidebar with bullets, and finally the toolbox without bullets. Anyway, I solved the problem by applying the CSS to a container/div that holds all of the sidebars, since I could not find out how to style them separately. So problem solved for me now. The extension works just as intended in all other ways, that's very nice. HelenaH 06:53, 21 November 2010 (UTC)
 * the code in your skin file is probably in the function customBox if you are using a skin based off one of the default skins. as far as using class='generated-sidebar portlet', that's actually TWO classes, generated-sidebar and portlet  .. if you add css for generated-sidebar you're likely to get what you wanted --Frantik 15:11, 21 November 2010 (UTC)

Example wikis would be nice
Example wikis would be nice. Adamtheclown 07:22, 25 December 2010 (UTC)

Seriously! This is setup for only experts to use. How does someone create a global sidebar on the right hand side like the one shown in this wiki? What files do they edit etc? (anon)

Can't get per-namespace sidebars working in 1.16
We have three custom namespaces - C1, C2, and C3. Localsettings.php is set up like so: require_once("$IP/extensions/CustomSidebar/CustomSidebar.php"); $wgDefaultSideBarText = 'MediaWiki:Sidebar'; $wgDefaultSideBarNSText[NS_C1] = 'Template:C1Sidebar'; $wgDefaultSideBarNSText[NS_C1_TALK] = 'Template:C1Sidebar'; $wgDefaultSideBarNSText[NS_C2] = 'Template:C2Sidebar'; $wgDefaultSideBarNSText[NS_C2_TALK] = 'Template:C2Sidebar'; $wgDefaultSideBarNSText[NS_C3] = 'Template:C3Sidebar'; $wgDefaultSideBarNSText[NS_C3_TALK] = 'Template:C3Sidebar';

However, no changes appear to the sidebar in the Cx: pages. I've tried making the template pages with and without the tags, to no avail. Suggestions? 75.72.21.98 04:41, 8 January 2011 (UTC)
 * Have you defined NS_C1, etc in your default settings file? are there any error messages?  does this work?

$wgDefaultSideBarText['ns'][NS_C1] = .... --Frantik 04:48, 19 February 2011 (UTC)

I have the same problem in 1.16.1 ($wgDefaultSideBarNSText... an $wgDefaultSideBarText['ns']... doesn't work, $wgDefaultSideBarGroupText... works). A workaround is (But as replacement, not additional Sidebar): $wgDefaultSideBarText = 'Template:Sidebar';


 * The problem appears to be a typo. Using $wgDefaultSidebarNSText (note the lowercase b) works. Twisted86 19:29, 24 January 2012 (UTC)

Global Modifications
Is there a method by which I can create a single Sidebar change that is applied globally throughout my Wiki? One might suggest applying a change to multiple namespaces, but I don't want to go through the labor of listing all of my namespaces so the Sidebar change is applied globally. My application of this extension is essentially calling out the active user's U/N in the sidebar using the following method in Mediawiki:Sidebar -
 * {| class="wikitable"


 * http://mywiki.com/index.php/
 * }
 * }

I have set -
 * {| class="wikitable"

and I see my modification applied throughout the Wiki. The problem is the USERNAME magic word returns the active user's U/N correctly in the MAIN namespace, but in every other namespace it only returns the wikitext. --Enterprise user 16:42, 17 February 2011 (UTC)
 * $wgDefaultSideBarText = 'MediaWiki:Sidebar'
 * }
 * }
 * I recommend not setting the default sidebar to Mediawiki:Sidebar.. try

$wgDefaultSideBarText['global'] = "Template:CustomSidebar";
 * I just set up Template:CustomSidebar with

* Menu ** |  User Page


 * and it worked as expected --Frantik 04:57, 19 February 2011 (UTC)

Additional sidebar elements for logged-in users
The page for this extension claims that sidebars (or sidebar elements?) can be defined based on user groups. I’m presuming that doing so for any logged-in user, one would have to:
 * 1. add the line $wgDefaultSideBarGroupText['user'] = "Template:CustomSidebarUser"; (or some other name) to Localsettings.php
 * 2. create the template “Template:CustomSidebarUser” (or some other name) and add the menu there.

Using the above method, however, any visitor is able to view the elements intended for logged-in users only. I’m not sure what has gone wrong here, but I should probably first ask:
 * a. Can Template:CustomSidebarUser in the above example be nested as a sidebar element (e.g. on the page or in another sidebar template), or should one include two different sidebars on the same page, a regular one for any visitor and another for logged-in users?
 * b. Should the template include the sidebar tags, or should the tags be added later (as in )?

The extension is otherwise working fine for me (though I haven’t tested the other parameters, such as those for category-specific sidebars). Cavila 10:51, 18 April 2011 (UTC)


 * I guess no one really knows then. If you want to add links to the sidebar for logged-in users only and this extension does not work for you either, maybe this script can help you out: User:Hoggwild5/ExtraSidebar. Cavila MW 1.17, MySQL 5.5.16, Php 5.3.8 20:06, 27 December 2011 (UTC)
 * You can define the actual sidebar text in the string, as opposed to referring to a page on the wiki.. ie:

$wgDefaultSideBarGroupText['user'] = " * Somepage | Sidebar link 1 * Another page | Sidebar link 2 ";
 * --Frantik (talk) 22:31, 11 March 2012 (UTC)

Compatibility with the Collection extension
This extension makes the sidebar/toolbox of the collection extension, is there a way to put it back?--Tsouchon 14:40, 26 May 2011 (UTC)

Not working on MediaWiki 1.11.2
On MediaWiki 1.11.2 the sidebar is always the default one. Is there any way to make it work on this old version? Thanks.

edit: Hook is from 1.14, so never mind.

set active link
in line 198 'active' => false replace by 'active' => ($wgTitle->getLocalURL == $href) --Pastakhov 15:02, 23 December 2011 (UTC)

Custom Sidebar for Group 'user' dont Work
Hallo, i try to set a custom sidebar for all sign in users with: $wgDefaultSideBarGroupText['user'] = "MediaWiki:CustomSidebarUser"; but it dont works. Only the default MediaWiki:Sidebar, that ist used for anonymous user, is displayed. With all other groups (sysop, custom groups, etc) it works fine. I already tried it with: $wgDefaultSideBarGroupText['user'] = " * Page | Name ** Page | name "; but it dont work either. Sys-Info MediaWiki 1.18.4 PHP 5.3.13 (cgi-fcgi)

Custom Sidebar doesn't render
I have version 0.3.0 installed with Mediawiki 1.20.2 (and php 5.3.10). I copied the example into a test page on my wiki but nothing in the sidebar changes. Apart from loading the extension, is there anything else that needs to be configured in LocalSettings.php? I have checked Special:Version to make sure it's loaded, and also checked the php and errors logs for any problems but nothing wrong there.

I fixed this by commenting out the following line in my LocalSettings.php $wgEnableSidebarCache = true;

Having problems with the basics of setup
Hi Frantik,

Thank you for producing this extension it's exactly what I would like to achieve with my Wiki implementation. Unfortunately I'm having problems with the basics so if you or anybody else could put me straight on the what I'm doing wrong then I'd much appreciate it.

Initially I just want to change the navigation menu for all users who view an extension that I'm building. My intial reading was that with my extension being 'Special:FeedReader', I might be able to include Template:TestSidebar as follows:

But I know that I've gotten this horribly wrong somewhere along the way.

Here's what I have:

In LocalSettings.php I have added two lines:

TestSidebar is just a page called Template:TestSidebar with the following contents:

These are the only changes that I have made to reference the extension from within its folder.

Product	Version

MediaWiki	1.17.0

PHP	5.3.3 (apache2handler)

Thanks in advance


 * hi, you don't need to use the tags on that page. The sidebar tags are for embedding the sidebar code directly on a page (vs using $wgDefaultSidebarText) --Frantik (talk) 05:47, 26 August 2014 (UTC)

Bug with $wgDefaultSideBarText = ':/Sidebar';
I didn't know where you wanted posts for bugs but I discovered a bug with some Mediawiki namespace pages using:

$wgDefaultSideBarText = ':/Sidebar';

Pages in NS_MEDIAWIKI use any subpage name to show the default value of the system message. e.g MediaWiki:Uploadtext which was changed, however if you go to:- You will see all the links to different subpage all contain the default value for the system message of Uploadtext.
 * MediaWiki:Uploadtext/Sidebar
 * MediaWiki:Uploadtext/Menubar
 * MediaWiki:Uploadtext/Foobar

Unfortunately, the  check for processing everything between   is being completely ignored. Since the default text of my example system message page contains bullets (*), the contents of each * is being written as a top sidebar element. Hutchy68 (talk) 17:59, 19 February 2014 (UTC)

Adding images possible?
does CustomSidebar allow displaying images in the sidebar?Gleki.arxokuna (talk) 12:54, 14 July 2014 (UTC)


 * I have not tried this, but I suspect that it may not work. However, if it is only about adding images to the sidebar the PCR GUI Inserts extension may be worth a look for you. Cheers --&#91;&#91;kgh&#93;&#93; (talk) 14:16, 12 August 2014 (UTC)

Issues with MW 1.23.x
I just tried out this extension and found that the  parameter is being ignored completely. Then using the  parameter, the contents of the templates gets appended to the standard sidebar added via "MediaWiki:Sidebar" and does not replace it. What I have done to get this working on a namespace basis with the current code is that I have blanked "MediaWiki:Sidebar" and defined at template to be used for every namespace. It will be great to have a fix since this is quite a popular extension with currently 175 wikis using it. I do not know what the situation is with earlier versions of MediaWiki (< MW 1.23) and I have not tested the tags provided. Cheers --&#91;&#91;kgh&#93;&#93; (talk) 14:21, 12 August 2014 (UTC)
 * thanks, I will update the source code --Frantik (talk) 05:43, 26 August 2014 (UTC)


 * Hi I just tested this extension and also found the  parameter is being ignored completely. I didn't test the NSText parameter, but definitely the extension is not working right on the current version of Mediawiki (1.23.6).  Christharp (talk) 17:32, 25 November 2014 (UTC)

Issues with MW 1.24
To fix this extension for MW 1.24+, try this substitution on approx. line 60:

global $wgLang, $wgTitle, $wgArticle, $wgDefaultSideBarText, $wgUser, $wgDefaultSideBarGroupText, $wgDefaultSidebarNSText;

$NewSideBar = false;

if (isset($wgArticle) and $wgArticle) {        $pagetext = $wgParser->preprocess( $wgArticle->getContent, $wgArticle->getTitle, ParserOptions::newFromUser( $wgUser ));

becomes:

global $wgLang, $wgTitle, $wgDefaultSideBarText, $wgUser, $wgDefaultSideBarGroupText, $wgDefaultSidebarNSText;

$NewSideBar = false;

$context = RequestContext::getMain; $wgArticle = $context->getWikiPage; if (isset($wgArticle) and $wgArticle) {        $pagetext = $wgParser->preprocess( ContentHandler::getContentText( $wgArticle->getContent, $wgArticle->getTitle, ParserOptions::newFromUser( $wgUser ));

Adding custom sidebar for logged in users (FIXED!)
For those of you trying to add a custom sidebar for members of group "user", I think I found the solution. In, change line 94 from:

to:

Anyway, it at least worked for me.

Kjvowen (talk) 18:23, 15 September 2015 (UTC)