Questions answered by this recipe!! Question
Is it possible to build an expanding menu showing only those links related to the current page?
The trailmenu.phpΔ script allows an author to use a WikiTrail to build an editable, expanding navigation menu. It is based largely on the Cookbook-V1/Trail2Menu script authored by Niall Durham, but has been updated here to work with PmWiki 2.0.
This script allows any WikiTrail to be used as the source for an expanding menu. For example, given a trail such as the following:
* [[Cookbook]] ** [[Skins]] *** GeminiSkin *** LinesSkin *** LightSkin *** LeanSkin ** [[Cookbook#markup | Markups]] *** MarkupExtended *** EnableHTML *** PostItNotes ** [[Cookbook#menus | Menus]] *** TreeMenu *** TrailMenu *** TrackingMenu *** ExpandingMenu ** [[Cookbook#uploads | Uploads]] *** UploadTypes *** AttachLinks * [[PmWiki]] ** [[PmWiki/DocumentationIndex]] ** [[Installation]]
Note that only those entries in the trail that are somehow related to the current page are displayed. ("Related" in this case means "direct descendents, direct ancestors, and ancestors' siblings".)
This is just a first cut at this recipe, improvements and comments are welcome.
Next, create a trail containing the page links to be displayed in the menu, using deeper levels of bullets to indicate submenus.
Finally, use the markup
Notes and Comments
The original trailmenu does not work with pmwiki-2.2.x. Cause: In 2.2.x the
I wish, someone would create a new type of menu, combining the advantages of TrailMenu and ExpandingMenu. As TrailMenu builds its list of menu items from a WikiTrail, no external urls or using headings is allowed. TrailMenu has the disadvantage of relying on building its menu items from WikiGroups - why should one have to create Groups only to be able to use them in a menu. Now a perfect menu would be called with a directive like Expanding Menu and thus still be able to build its item list from a simple unordererd list like TrailMenu, but not relying on the disadvantages of a WikiTrail.
You may want to have a look at the brand new Cookbook.DynTrailMenu recipe.