Extension talk:CustomSidebar

From MediaWiki.org
Jump to: navigation, search

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

Contents

[edit] TOC in sidebar

Why doesn't

<sidebar>__TOC__</sidebar>

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)

[edit] <sidebar> not transcluded from templates

I'm trying to add a custom sidebar through a template. I've put a custom sidebar (using the <sibebar> 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 <sibebar> tags appear between <includeonly> 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 <sibebar> 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)

[edit] 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 = 'Extension talk:CustomSidebar/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?:
<?php foreach ($this->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)

[edit] 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: <div class='generated-sidebar portlet' id='p-.C2.A0'>. 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)

[edit] 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)

[edit] 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 <sidebar></sidebar> 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:{{NAMESPACE}}Sidebar';
The problem appears to be a typo. Using $wgDefaultSidebarNSText (note the lowercase b) works. Twisted86 19:29, 24 January 2012 (UTC)

[edit] 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 -

http://mywiki.com/index.php/{{#__USERNAME}}

I have set -

$wgDefaultSideBarText = 'MediaWiki:Sidebar'

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 {{#__USERNAME}}. --Enterprise user 16:42, 17 February 2011 (UTC)

I recommend not setting the default sidebar to Mediawiki:Sidebar.. try
$wgDefaultSideBarText['global'] = "Template:CustomSidebar";
I just set up Template:CustomSidebar with
* Menu
** {{#__USERNAME}} |  User Page
and it worked as expected --Frantik 04:57, 19 February 2011 (UTC)

[edit] 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 <sidebar>{{…}}</sidebar> )?

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)

[edit] 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)

[edit] 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.

[edit] set active link

in line 198

'active' => false

replace by

'active' => ($wgTitle->getLocalURL() == $href)

--Pastakhov 15:02, 23 December 2011 (UTC)

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox