ExpandingMenu

Summary: A sidebar menu that supports nested lists where the nested items are displayed only if the user is in that group
Version:
Prerequisites:
Status:
Maintainer: dstebila
Discussion: ExpandingMenu-Talk
Categories: Menus, Layout, Markup, PHP72

Not to be confused with ExpandingMenus.

Goal

A sidebar menu that supports nested lists where the nested items are displayed only if the user is in that group.

Features

  • No JavaScript
  • No custom markup
  • CSS compatible

Solution

Put emenu.phpΔ in your cookbook directory (you may have to create it).

Add the following line to local/config.php:

    include_once("cookbook/emenu.php");

Use

Decorate your existing sidebar menu with (:emenu:) and (:emenuend:) directives.

From the technical point of view, (:emenu:) adds a <div class="emenu"> around the menu which can be modified with CSS.

It does not affect any other lists outside (:emenu:) blocks.

Example (copy and paste to your side bar)

(:emenu:)
* [[Main/Home Page]]
* [[Main/WikiSandbox]]
* [[PmWiki/Documentation Index]]
** [[PmWiki/Installation]]
** [[PmWiki/Release Notes]]
** [[PmWiki/ChangeLog]]
* [[Cookbook/Cookbook]]
** [[Cookbook/Administration]]
** [[Cookbook/Uploads]]
** [[Cookbook/Blog]]
(:emenuend:)

In this example, when the user is on any page in the Main group, only the first three items in the menu are displayed. When the user is on any page in the PmWiki group, all the menu items are displayed.

See also

  • ExpandingMenus for a solution using conditional markup instead (no script needed).

Contributors

  • dstebila, 17-Apr-2005
  • Petko June 28, 2018, at 09:49 AM, update for PHP 5.5 and 7.2

Comments

See discussion at ExpandingMenu-Talk