Extension:SideBarMenu
![]() | This extension is incompatible with MediaWiki 1.35 or any later release! You are advised against using this extension on a live site. Volunteer developers are invited to pledge their efforts to updating this extension to make it compatible with MediaWiki 1.39 by replacing the {{Incompatible }} template with {{Incompatible |version=1.35|pledge=~~~~}} . |
![]() | This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored. If you are interested in taking on the task of developing and maintaining this extension, you can request repository ownership. As a courtesy, you may want to contact the author. You should also remove this template and list yourself as maintaining the extension in the page's {{extension}} infobox. |
![]() Release status: unmaintained |
|
---|---|
![]() |
|
Implementation | Parser extension , Tag |
Description | Allows for a simple sidebar menu which supports infinite number of sub-menus. |
Author(s) | Kim Eik (Netbraintalk) |
Latest version | 0.2 (2013-10-16) |
MediaWiki | MW 1.17+ |
PHP | 5.3+ |
Database changes | No |
Composer | mediawiki/side-bar-menu |
License | GNU General Public License 3.0 or later |
Download | |
$wgSideBarMenuConfig |
|
<sidebarmenu> |
|
Quarterly downloads | 38 (Ranked 140th) |
Translate the SideBarMenu extension if it is available at translatewiki.net | |
The SideBarMenu extension allows the creation of multilevel menus through the tag <sidebarmenu/>
Installation[edit]
Download and install using Composer, as of c1730 this is the only way of installing and running this extension (however not verified).
- Download and place the file(s) in a directory called
SideBarMenu
in yourextensions/
folder. - Add the following code at the bottom of your
LocalSettings.php
:require_once "$IP/extensions/SideBarMenu/SideBarMenu.php";
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Configuration parameters[edit]
Name | Description | Global example usage | Instance example usage | Default setting |
---|---|---|---|---|
show | Sets the text to be displayed on expandable menu items | $wgSideBarMenuConfig['show'] = '[show]';
|
<sidebar show="[show]"> | null
|
hide | Sets the text to be displayed on collapsable menu items | $wgSideBarMenuConfig['hide']= '[hide]';
|
<sidebar hide="[hide]"> | null
|
animate | Whether to use animations when expanding/collapsing menuitems | $wgSideBarMenuConfig['animate'] = true;
|
<sidebar animate="true"> | true
|
expanded | Default behavior of menuitem nodes when no expand/collaps flag is supplied in sidebarmenu tag syntax | $wgSideBarMenuConfig['expanded'] = true;
|
<sidebar expanded="true"> | true
|
editlink | Shows/hides a edit link which points to the edit page wherever the sidebarmenu is declared | $wgSideBarMenuConfig['editlink'] = true;
|
<sidebar editlink="true"> | true
|
minimized | Menu starts out as minimized if true | $wgSideBarMenuConfig['minimized'] = false;
|
<sidebar minimized="true"> | false
|
Styling[edit]
You can use CSS to customize the appearance of the sidebar and override the default CSS styles. To get started take a look in the file /css/ext.sidebarmenu.css.
You can also override css styles on a per menu item level. The styles will attach itself to the <li> tag. You can override css styles in two ways:
- using the style parameter. e.g **MenuItem|style=font-weight:bold;font-size:16px;
- using the class parameter. e.g **MenuItem|class=some-defined-css-class another-css-class
As a late addition, you can also set the class property on the sidebarmenu tag to add custom classes to the root container of the sidebarmenu. This way you can create your own stylesheet and have several sidebarmenu's with their own styling.
Example:
<sidebarmenu class="myCustomClass"> +MyMenuElement1 *MyMenuElement2 </sidebarmenu>
Through this method you could make the sidebarmenu look completely different.
Syntax explanation[edit]
- Each newline represents a new menu item.
- The first character of a line (either '+' or '-') determines if the menu item's children are visible or hidden
- The number of '*' characters determines where in the tree the menu item should be placed.
- A '@' prefix of a menu item, makes that menu item clickable which in turn expands or collapses submenu.
- The rest of the line is interpreted as wikitext.
- The input also accepts other mediawiki syntax, e.g <sidebarmenu>{{Template}}</sidebarmenu>
- #subpage <page> would render a tree of subpages in the sidebarmenu.
#subpage[edit]
Given that the wiki is configured with $wgNamespacesWithSubpages , and that the pages A, A/B, and A/B/C exists. A syntax of:
<sidebarmenu> #subpage A </sidebarmenu>
Would be the equivalent of:
<sidebarmenu> [[A|A]] *[[A/B|B]] **[[A/B/C|C]] </sidebarmenu>
The -/+ syntax can be used on the subpage functionality to give each element a prefix of +/- in the entire subtree.
See also: https://gerrit.wikimedia.org/r/#/c/90536/
Example syntax[edit]
MenuItem1 <-- root menu item *Child1 <-- child of MenuItem1 **Child2 <-- child of Child1 *Child3 <-- child of MenuItem1 +@MenuItem2 <-- new root menu item which has it's children visible (also clickable) -*Child1 <-- child of MenuItem1 which has it's children hidden **Child2 <-- child of Child1'''' *#subpage A <-- child of MenuItem1 which populates the tree with the page A and it's subpages {{Template}} <-- Wiki code that is evaluated, in this case a template inclusion
'+' or '-' determines whether the menu item should be expanded or collapsed, if neither is supplied at the beginning of a line then the default configured ('expanded') will decide.
The number of '*' characters determines the location in the hierarchy for the menuitem.
Note that wiki code evaluation needs to return a valid sidebarmenu syntax.
Example usage[edit]
The following code;
<sidebarmenu>
+[[Vehicle]]
+*[[Car]]
**[[Sports car]]
**[[Family car]]
***[[Large family car]]
***[[Small family car]]
+*[[Truck]]
**[[Fire truck | FIRE TRUCK]]
**[[Garbage truck]]
**[[Flatbed truck]]
**[[Tow truck]]
</sidebarmenu>
will result in the following (not entirely true as some changes has been made to the sourcecode): (Tip: You can now also give each menu item a different display name e.g [[Monster_Truck|Monster truck]] would display "Monster truck" instead of "Monster_Truck")