====== navi Plugin ====== ---- plugin ---- description: Build a navigation menu from a list author : Andreas Gohr email : dokuwiki@cosmocode.de type : syntax lastupdate : 2023-02-15 compatible : Detritus, Hrun, Elenor Of Tsort, Greebo, Hogfather, Igor depends : conflicts : similar : indexmenu tags : navigation, menu alter : true sourcerepo : https://github.com/cosmocode/navi downloadurl: https://github.com/cosmocode/navi/zipball/master bugtracker : https://github.com/cosmocode/navi/issues ---- 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 ===== [[https://www.cosmocode.de/en/open-source/dokuwiki-plugins/|{{ https://www.cosmocode.de/static/img/dokuwiki/dwplugins.png?recache|A CosmoCode Plugin}}]] Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually. ==== Changes ==== {{rss>https://github.com/cosmocode/navi/commits/master.atom date}} ===== Usage ===== In the page defining the sidebar in your template add the following syntax: {{navi>mycontrolpage}} where ''mycontrolpage'' 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 [[:namespaces|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>mycontrolpage?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>mycontrolpage?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>mycontrolpage?ns&js}}