Extension:CustomSidebar

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
CustomSidebar

Release status:Extension status stable

ImplementationTemplate:Extension#type User interface, Parser extension
DescriptionTemplate:Extension#description Easy system for specifying custom sidebars on a per-page basis
Author(s)Template:Extension#username SwiftlyTilting (Frantiktalk)
Latest versionTemplate:Extension#version 0.3.0 (2009-08-09)
MediaWikiTemplate:Extension#mediawiki 1.14-1.23
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license GNU General Public License 2.0 or later
Download Download v0.3.0
ParametersTemplate:Extension#parameters
  • $wgDefaultSideBarText
  • $wgDefaultSidebarNSText
  • $wgDefaultSideBarGroupText
TagsTemplate:Extension#tags
sidebar
Hooks usedTemplate:Extension#hook
SkinBuildSidebarManual:Hooks/SkinBuildSidebar

Translate the CustomSidebar extension if it is available at translatewiki.net

Check usage and version matrix.

The CustomSidebar extension provides an easy way to customize the sidebar on a per-page basis. You may define the sidebar in-page or reference another page which contains the text. The sidebar text takes the same format as Mediawiki:sidebar, and also supports Templates and Magic words.

Usage[edit]

<sidebar>sidebartext</sidebar>

sidebartext may contain the following elements. If the text does not return any valid elements, the default sidebar MediaWiki:Sidebar is used.

Standard MediaWiki:Sidebar syntax[edit]

You may specify the main layout of the sidebar using standard sidebar syntax.

Example:

<sidebar>
* Menu
** link1|Text 1
** link2|Text 2 
</sidebar>

Reference to another page[edit]

If the sidebartext only contains a page name and no asterisks, that page will be used as the sidebar text. Any page in any namespace may be used.

Example:

<sidebar>wiki page name</sidebar>

Magic words and Template Support[edit]

Version 0.3.0 adds full template support.

Version 0.2.0 adds Magic words and simple template.

Magic Words[edit]

You may use any of the default Magic words within the sidebar text, or custom magic words listed below:

Custom magic words[edit]

{{#__USERNAME}} - Returns the current username.

Simple Template Support in v0.2.0[edit]

Versions 0.3.0 and higher support full template syntax. The code is processed by Mediawiki itself.

In v0.2.0, a custom processing engine was used. Templates with zero or one unnamed parameter will be transcluded as expected. Nested calls are not allowed, but included template pages will be processed recursively.

Example:

# OK
{{TemplateName}}
{{TemplateName|parameter}}

# Not ok in v0.2.0
{{TemplateName|param = parameter}}
{{TemplateName|1|2|3}}
{{{{NAMESPACE}}:TemplateName}}

Parameters[edit]

$wgDefaultSideBarText[edit]

Added in v0.1.0

The text $wgDefaultSideBarText is similar to setting MediaWiki:Sidebar, only it can be set within LocalSettings.php and can use variables and templates. Example: This sidebar text will allow you to specify a sidebar for each "sub directory"

$wgDefaultSideBarText = '{{NAMESPACE}}:{{BASEPAGENAME}}/Sidebar';

Using the above example, the contents of foo/Sidebar would be applied to the following pages as sidebar text

  • foo
  • foo/page 1
  • foo/page 2
  • foo/page 3
  • foo/etc

You can also use the default sidebar, though it is recommended to use a different page as the default sidebar, so that MediaWiki:Sidebar can be used in case the processed sidebar text does not return a valid sidebar.

$wgDefaultSideBarText = 'MediaWiki:Sidebar';

$wgDefaultSidebarNSText[edit]

Added in v0.3.0

Defines an additional sidebar based on the namespace. Syntax is the same as $wgDefaultSideBarText

$wgDefaultSidebarNSText[NS_TALK] = "Template:CustomSidebarTalk";

(Note the lowercase b in Sidebar)

$wgDefaultSideBarGroupText[edit]

Added in v0.3.0

Defines an additional sidebar based on groups. Syntax is the same as $wgDefaultSideBarText

$wgDefaultSideBarGroupText['sysop'] = "Template:CustomSidebarSysop";

Installation[edit]

  • Download and place the file(s) in a directory called CustomSidebar in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/CustomSidebar/CustomSidebar.php";
    
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Change Log[edit]

v.0.3.0
  • Added full template support
  • Added Custom sidebars based on user groups and namespaces
v.0.2.0
  • Added magic word and template support
v.0.1.0
  • First public release

See also[edit]