Recent Changes - Search:




Summary: How to create a sidebar menu which expands to show sublevel (group) items using conditional markup only
Status: Stable
Prerequisites: pmwiki-2.0
Votes: 5


How can I create a compact sidebar menu which expands to show sublevel items when clicking on first level items?


Make sure the skin you use can display first and second level list elements.

Build your Sidebar embracing selected list elements in an (:if group $Groupname :) ... (:if:) conditional directive. These will be displayed only if the page belongs to the specified group. This is most useful to hide second level list elements when not in their group. The sidebar menu must be structured in groups, so that secondary elements point to pages in a group, and an intro page link appears at the top. That gives the effect of opening up the group links when clicked on the intro page link.

Example SideBar

*[[GroupOne/GroupOne]] (:if group GroupOne:)
**[[GroupOne/Page3]] (:if:)
*[[GroupTwo/GroupTwo]] (:if group GroupTwo:)
**[[GroupTwo/Page6]] (:if:)
*PmWiki (:if group PmWiki:)
** [[PmWiki/Installation | Download and Install]]
** [[PmWiki/Tips For Editing]]
** [[PmWiki/Documentation Index]]
** [[PmWiki/FAQ]] (:if:)

To avoid having each group edit the Main.SideBar you can expand on this idea and allow each group to have its own SideBar-Menu page conditionally included like this:

Example SideBar

(:if group GroupOne:)(:include {$Group}.SideBar-Menu:)(:if:)
(:if group GroupTwo:)(:include {$Group}.SideBar-Menu:)(:if:)
(:if group PmWiki:)(:include {$Group}.SideBar-Menu:)(:if:)

Example Group.SideBar-Menu Note: You do not have to fully qualify the group pages.


  • This recipe was last tested on PmWiki version: 2beta26
  • This recipe requires at least PmWiki version: 2

See also



See discussion at ExpandingMenus-Talk

Edit - History - Print - Recent Changes - Search
Page last modified on February 15, 2014, at 12:15 PM