Present a table of content of the pages of a selected namespace
Compatible with DokuWiki
Similar to dirlisting, nstoc
This plugin nicely displays a table of content of the pages -and optionally the subnamespaces- of a given (sub)namespace.
Using this plugin is easy: just write
<nspages>
and see the result. (You may also use the button
from the toolbar.)
The general syntax is
<nspages path_to_a_namespace -option1 -option2 ...>
where:
| -subns | displays the subnamespaces of the selected namespace (and provide links to their main page) |
| -nopages | do not list the pages of the selected namespace (of course this option is useful only if you use -subns) |
| -exclude:nameOfPage | won't include the page nameOfPage. This option may be use several times in order to exclude several pages |
| -exclude:subNs: | won't include the subnamespace subNs. This option may also be used more than once |
| -exclude:[page1 subNs: page2] | an easier syntax to exclude several pages/subnamespaces |
| -exclude | won't include the current page |
| -h1 | will display the first h1 title found. If a page doesn't contain such a title, the name of the page is used instead |
| -textPages=“some text” | some text will be displayed instead of the default text, to introduce the pages list |
| -textNS=“some text” | some text will be displayed instead of the default text, to introduce the namespaces list |
| -title | alias of -h1 |
| -simpleList | display the list on a single column |
| -simpleLine | display the list on a single line (incompatible with -simpleList) |
| -pregPagesOn -pregPagesOff -pregNSOn -pregNSOff | Enable the use of regex to select the documents that should be displayed. Eg: -pregPagesOn=”/doku/i” will display only pages which contains “doku” in their id. Several options may be used, and each of them may be used several times. |
| -r | recurse : display elements of the subnamespaces. You may use just ”-r” to check every subnamespace, or e.g. ”-r=3” to have a depth limit to 3 levels |
| -nbCol=3 | Change the number of columns to use (default is 3) |
| -sortId | Sort the pages according to their id, even if -title is used |
ex: <nspages path_to_a_namespace -exclude> or <nspages -subns -nopages> will work.
If you have one of the latest version of DokuWiki (at least 2009-12-25, Lemmings), you may use this archive: http://github.com/gturri/nspages/zipball/master.
If you have a previous version of DokuWiki, you should use this one: http://guigui.webou.net/gestion_projet/nspages/nspagesV1.zip.1)
<nspages -title -r -subns -nbCol=2 -exclude:[wiki: playground: index] -pregNSOff="/ebook/" -pregPagesOff="/ebook/">''
But it doesn't work ond my DokuWiki Ricewind.
pregNSOff (resp. pregPagesOff) works on the id of the subnamespace (resp. the page), without taking the id of the parent namespaces into account. Therefore, using ”-pregNSOff=”/ebook/”” it expected to exclude this namespace from the “Subnamespace” section, but let the pages in this namespace pass.
I could add another set of options like pregNSWithFullIdOff / pregPagesWithFullIdOff, … to deal with it, but I'll first try to see if I can find a more clever solution. — gturrigturri
Paris 2011/12/31 13:42
Thanks, but how does the exclude works exactly. it doesn' excludewiki:oderplayground:in my case (but the page index). I'm looking for an option to exclude namespaces recursive (btw, happy new year) — Keywan Tonekaboni 01.01.2012 - 15:08If you're a bit familiar with PHP, here is how it works:
/** * Check if the user wants a file to be displayed. * Filters consider the "id" and not the "title". Therefore, the treatment is the same for files and for subnamespace. * Moreover, filters remain valid even if the title of a page is changed. * * @param Array $excludedFiles A list of files that shouldn't be displayed * @param Array $pregOn RegEx that a file should match to be displayed * @param Array $pregOff RegEx that a file shouldn't match to be displayed */ function _wantedFile($excludedFiles, $pregOn, $pregOff, $file){ $wanted = true; $noNSId = noNS($file['id']); $wanted &= (! in_array($noNSId, $excludedFiles) ); foreach ( $pregOn as $preg ){ $wanted &= preg_match($preg, $noNSId); } foreach ( $pregOff as $preg ){ $wanted &= !preg_match($preg, $noNSId); } return $wanted; }
In particular, the “noNS($file['id']);” means that each item is considered without it's namespace. Therefore the page “playground:mytest” will pass even if we put -exclude:playground: . More precisely: there isn't, yet, an option to exclude namespaces recursively. However, it seems a good idea to add one, so I may try to find some time to improve it in 2012 (but I'm afraid it won't be soon). — gturrigturri
Paris 2012/01/01 15:23
” <nspages -subns -r -simpleList>”, and had returned the following message when I tried to save the page: “this namespace doesn't exist: -r”.