plugin:navi
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:navi [2017-03-12 00:47] – changed, according to email of contact [at] nliautaud [dot] fr 2.242.103.173 | plugin:navi [2024-06-06 11:46] (current) – navigationmenu => mycontrolpage (better nudging) michaelsy | ||
---|---|---|---|
Line 6: | Line 6: | ||
email : dokuwiki@cosmocode.de | email : dokuwiki@cosmocode.de | ||
type : syntax | type : syntax | ||
- | lastupdate : 2016-10-12 | + | lastupdate : 2023-02-15 |
- | compatible : Detritus, Hrun, Elenor Of Tsort | + | compatible : Detritus, Hrun, Elenor Of Tsort, Greebo, Hogfather, Igor |
depends | depends | ||
conflicts | conflicts | ||
Line 22: | Line 22: | ||
===== Download and Install ===== | ===== Download and Install ===== | ||
- | [[http:// | ||
- | Use the download link above to either manually download | + | [[https:// |
+ | |||
+ | Search and install | ||
Line 35: | Line 36: | ||
In the page defining the sidebar in your template add the following syntax: | In the page defining the sidebar in your template add the following syntax: | ||
- | {{navi>navigationmenu}} | + | {{navi>mycontrolpage}} |
- | where '' | + | where '' |
Notes: | Notes: | ||
Line 45: | Line 46: | ||
* The list items should only contain links, any other syntax 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 | * 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 ==== | ==== Control Page Example ==== | ||
Line 67: | Line 69: | ||
Sometimes the navi plugin is used to create collapsible, | Sometimes the navi plugin is used to create collapsible, | ||
- | By adding ''? | + | By adding ''? |
+ | ==== Displaying the Full Tree and dynamic JS ==== | ||
- | ===== Mods ===== | + | Sometimes |
- | + | ||
- | ==== Persistent level2 ==== | + | |
- | + | ||
- | If you want the menu to always show the level2 items, and the deeper ones only when on the path, for example: | + | |
- | + | ||
- | one | + | |
- | two | + | |
- | three | + | |
- | four | + | |
- | five <- you are here | + | |
- | six | + | |
- | seven | + | |
- | height | + | |
- | + | ||
- | You can replace the line 190-192 of syntax.php by : | + | |
- | + | ||
- | <code php> | + | |
- | $diff = array_diff($info[' | + | |
- | if (!empty($diff) && isset($diff[1])) { | + | |
- | | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | This is tested and working with the plugin releas of 2016-10-12. | + | |
- | + | ||
- | --- [[contact@nliautaud.fr]] // | + | |
- | + | ||
- | ==== Add class if child has item ==== | + | |
- | I modified the function render | + | |
- | Menuitems will have '' | + | |
- | If no Child is defined there is no list item. | + | |
- | I add to the '' | + | |
- | --- [[user> | + | |
- | + | ||
- | <code css> | + | |
- | div.dokuwiki div.navigation li { | + | |
- | list-style: none; | + | |
- | margin-left: | + | |
- | } | + | |
- | div.dokuwiki div.navigation li.open | + | |
- | div.dokuwiki div.navigation li.close | + | |
- | div.dokuwiki div.navigation li.level1 { margin-left: | + | |
- | div.dokuwiki div.navigation li.level2 { margin-left: | + | |
- | div.dokuwiki div.navigation li.level3 { margin-left: | + | |
- | div.dokuwiki div.navigation li.level4 { margin-left: | + | |
- | div.dokuwiki div.navigation li.level5 { margin-left: | + | |
- | </ | + | |
- | + | ||
- | here is the mod | + | |
- | + | ||
- | <code php> | + | |
- | + | ||
- | /** | + | |
- | * Create output | + | |
- | * | + | |
- | * We handle all modes (except meta) because we pass all output creation back to the parent | + | |
- | * mod by Mark Wolfgruber 20.06.2011 | + | |
- | | + | |
- | */ | + | |
- | function render($format, | + | |
- | global $INFO; | + | |
- | global $ID; | + | |
- | $fn = $data[0]; | + | |
- | $opt = $data[2]; | + | |
- | $data = $data[1]; | + | |
- | + | ||
- | if($format == ' | + | |
- | $R-> | + | |
- | return true; | + | |
- | } | + | |
- | + | ||
- | $R-> | + | |
- | + | ||
- | $parent = array(); | + | |
- | if(isset($data[$INFO[' | + | |
- | $parent = (array) $data[$INFO[' | + | |
- | array_push($parent, | + | |
- | $current = $INFO[' | + | |
- | }elseif($opt == ' | + | |
- | $ns = $INFO[' | + | |
- | + | ||
- | // traverse up for matching namespaces | + | |
- | | + | |
- | $ns = getNS($ns); | + | |
- | $try = " | + | |
- | resolve_pageid('', | + | |
- | if(isset($data[$try])){ | + | |
- | // got a start page | + | |
- | $parent = (array) $data[$try][' | + | |
- | array_push($parent, | + | |
- | $current = $try; | + | |
- | break; | + | |
- | }else{ | + | |
- | // search for the first page matching the namespace | + | |
- | | + | |
- | if(getNS($key) == $ns){ | + | |
- | $parent = (array) $data[$key][' | + | |
- | array_push($parent, | + | |
- | $current = $key; | + | |
- | break 2; | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | + | ||
- | } while($ns); | + | |
- | } | + | |
- | + | ||
- | // we need the top ID for the renderer | + | |
- | $oldid = $ID; | + | |
- | $ID = $INFO[' | + | |
- | + | ||
- | // create a correctly nested list (or so I hope) | + | |
- | // $open = false; /** deacivated | + | |
- | $lvl = 1; | + | |
- | $R-> | + | |
- | + | ||
- | // read if item has childs and if it is open or closed /** mod by mark **/ | + | |
- | $upper=array(); | + | |
- | foreach((array) $data as $pid => $info){ | + | |
- | $state=(array_diff($info[' | + | |
- | $countparents=count($info[' | + | |
- | if ( $countparents > ' | + | |
- | for($i=0; $i < $countparents; | + | |
- | $upperlevel=$countparents-1; | + | |
- | $upper[$info[' | + | |
- | } | + | |
- | } | + | |
- | } /** mod by mark **/ | + | |
- | unset($pid); | + | |
- | + | ||
- | // read if item has childs if it is open or closed | + | |
- | foreach((array) $data as $pid => $info){ | + | |
- | // only show if we are in the " | + | |
- | if(array_diff($info['parents'],$parent)) continue; | + | |
- | + | ||
- | if ($upper[$pid]) { /** mod by mark **/ | + | |
- | $menuitem=($upper[$pid]=='open') ? 'open' : ' | + | |
- | } else { | + | |
- | $menuitem=''; | + | |
- | } /** mod by mark **/ | + | |
- | + | ||
- | // skip every non readable page | + | |
- | if(auth_quickaclcheck(cleanID($info[' | + | |
- | + | ||
- | if($info[' | + | |
- | // if($open) $R-> | + | |
- | $R-> | + | |
- | // $open = true; /** deacivated by mark **/ | + | |
- | }elseif($lvl > $info[' | + | |
- | for($lvl; $lvl > $info[' | + | |
- | // $R-> | + | |
- | // $R-> | + | |
- | } | + | |
- | // $R-> | + | |
- | $R-> | + | |
- | }elseif($lvl < $info[' | + | |
- | // more than one run is bad nesting! | + | |
- | for($lvl; $lvl < $info[' | + | |
- | // $R-> | + | |
- | $R-> | + | |
- | // $open = true; /** deacivated by mark **/ | + | |
- | } | + | |
- | } | + | |
- | + | ||
- | $R-> | + | |
- | if(($format == ' | + | |
- | $R-> | + | |
- | if(($format == ' | + | |
- | $R-> | + | |
- | $R-> | + | |
- | } | + | |
- | /* while($lvl > 0){ | + | |
- | $R-> | + | |
- | $R-> | + | |
- | $lvl--; | + | |
- | } /** deacivated by mark **/ | + | |
- | $R-> | + | |
- | + | ||
- | $ID = $oldid; | + | |
- | + | ||
- | return true; | + | |
- | } | + | |
- | + | ||
- | </ | + | |
- | + | ||
- | ===== BUG ===== | + | |
- | ==== first submenu item level1 instead level2 ==== | + | |
- | + | ||
- | i tried this plugin and have a problem with the first submenu item. it have to be in the div class level2 but it became level1 after the script did his work --- [[user> | + | |
- | + | ||
- | > found the error: | + | |
- | > replace $lvl with $info[' | + | |
- | + | ||
- | < | + | |
- | }elseif($lvl < $info[' | + | |
- | // more than one run is bad nesting! | + | |
- | for($lvl; $lvl < $info[' | + | |
- | $R-> | + | |
- | $R-> | + | |
- | $open = true; | + | |
- | } | + | |
- | + | ||
- | </ | + | |
- | ==== Rendering Bugs ==== | + | {{navi> |
- | The closing of open menu entries does not work. | + | If you want to use the full hierarchy but be able to open without page reloads, you can use the '' |
- | The open menu child entries are on the same level like the main menu entries. | + | |
- | The user does not see any indicator for child menu items if the main menu is closed. | + | |
- | Tested with the code modifications on this page with Dokuwiki dokuwiki-rc2011-11-10.tgz “Angua”. | + | {{navi> |
- | HH 29.12.2011 | + | |
plugin/navi.1489276071.txt.gz · Last modified: by 2.242.103.173