DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:navi

navi Plugin

Compatible with DokuWiki

  • 2024-02-06 "Kaos" unknown
  • 2023-04-04 "Jack Jackrum" unknown
  • 2022-07-31 "Igor" yes
  • 2020-07-29 "Hogfather" yes

plugin Build a navigation menu from a list

Last updated on
2023-02-15
Provides
Syntax
Repository
Source
Conflicts with
yalist

Similar to indexmenu, navilevel, simplenavi

Tagged with menu, navigation

Needed for grassstains, zenlike

This plugin allows you to create a nested navigation menu based on a list defined in a Wiki page. Lower navigation levels are shown or hidden dependent on the current page. It is intended for the use in the sidebar of a template supporting one (tested on Arctic). A notable feature is that it allows you to create hierarchical menus without the need of a hierarchical namespace structure.

Download and Install

A CosmoCode Plugin

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Changes

Usage

In the page defining the sidebar in your template add the following syntax:

{{navi>navigationmenu}}

where navigationmenu is any other page containing an unordered list of page links — this page we call the “control page”.

Notes:

  • The created menu is completely independent of any namespace structure. The hierarchy is created by the list nesting only. Exception: when the ?ns option is used (see below)
  • The navigation menu page should contain exactly one unordered list, other content will be ignored
  • The list items should only contain links, any other syntax will be ignored
  • Each page linked in the list should occur only once
  • Displayed links are dependent on user permissions. When the current user can not read a page it will not be shown (neither will any pages further down the hierarchy)

Control Page Example

The following would create a menu with 4 top level entries: “Welcome”, “Products”, “Service” and “Wiki Syntax”. When you are on the “Products” page, the sub entries “Foomatic 2000” and “Foomatic 2010” are visible.

  * [[start|Welcome]]
  * [[Products]]
    * [[Foomatic 2000]]
    * [[Foomatic 2010]]
  * [[Service]]
    * [[about|About Foo Inc.]]
    * [[Contact]]
  * [[syntax|Wiki Syntax]]

This allows you to create hierarchical menus without the need of a hierarchical namespace structure.

Making use of Namespaces

Sometimes the navi plugin is used to create collapsible, editable navigation even though content is structured into nested namespaces. But since the plugin knows nothing about those namespaces by default it will collapse completely as soon as a page is opened that is not defined in the control page.

By adding ?ns to the navi plugin syntax, e.g. {{navi>navigationmenu?ns}}, you can make the plugin to be clever about namespaces: When it is called on a page that is not mentioned on the control page, it will have a look at the namespace of the page. It then checks if a startpage for the namespace is to be found in the control page. If it is, it will be used as the current open branch, if not it is checked if there is any other page in the same namespace on the controlpage. If found it's used. This is repeated for each higher namespace until the top is reached or a matching page.

Displaying the Full Tree and dynamic JS

Sometimes you may want to display the full navigation hierarchy (but still leave out pages without permission). Especially template authors may want to use this feature for mobile menus and such. You can do this by adding the full parameter:

{{navi>navigationmenu?ns&full}}

If you want to use the full hierarchy but be able to open without page reloads, you can use the js parameter:

{{navi>navigationmenu?ns&js}}
plugin/navi.txt · Last modified: 2024-01-25 09:05 by andi

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki