nspages plugin

Compatible with DokuWiki

  • 2012-01-25 "Angua" yes
  • 2011-05-25 "Rincewind" yes
  • 2010-11-07 "Anteater" yes

plugin Present a table of content of the pages of a selected namespace

Last updated on
2011-08-25
Provides
Syntax
Repository
Source

Similar to dirlisting, nstoc

Tagged with listing, menu, namespace, navigation

Description

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:

  • path_to_a_namespace represents the path to the wanted namespace. It can be an absolute (ex: namespace1:subnamespace) or a relative path (ex: .:subnamespace). If no path is specified, the current namespace is selected.
  • -option may be one of the following (it is possible to specify several options):
-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.

Installation

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)

Latest changes

Some (important) points

  • You should put ~~NOCACHE~~ in the pages where you use this plugin, to make sure that if you create or remove a page in the namespace, it will be taken into account. Else, it may take up to 24h to be updated. However, it's up to you: if you seldom create/remove pages, you may want to avoid putting this; to save CPU cycles.
  • The CSS sheet should be taken into account in order for this plugin to work correctly; but because of the cache system it may not be the case the first time you use this plugin (even if ~~NOCACHE~~ is specified). The easier way to resolve this is to make sure your cache is invalidated by touching conf/local.php (eg. by resaving your configuration)
  • Currently, you may not use a '>' in the -textPages and -textNS options, since it is understood as the end of the <nspages> tag

Questions

  • I tried nspages, but have some problems with the syntax. I would like to exclude all pages from the NS wiki: and ebook:
<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' exclude wiki: oder playground: 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:08
If 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



  • I tried nspages, but I had problems with the -r syntax. I wrote:

” <nspages -subns -r -simpleList>”, and had returned the following message when I tried to save the page: “this namespace doesn't exist: -r”.

  • It could be due to an old version of the plugin since it can't reproduce this issue. Could you please try to install the last version and tell me if it fixes your issue? If it doesn't, could you please give me an url where I could observe this bug? — gturrigturri

    Paris
    2012/01/11 08:33
1) which is an older version of this plugin.
plugin/nspages.txt · Last modified: 2012/01/11 08:33 by 91.199.242.236
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsGitXRefTranslate