Table of Contents

nspages Plugin

Compatible with DokuWiki

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

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

Last updated on
2024-01-04
Provides
Syntax
Repository
Source

If your Dokuwiki instance is older than the release “Igor - 2022-07-31” you should use the version available here (and NOT update it afterward), because subsequent versions of the plugin won't be compatible)

This plugin nicely displays a table of content of the pages -and optionally the subnamespaces- of a given (sub)namespace.

If you're discovering this plugin and want to have a glimpse at what you can do with it, the first section, which shows some common usages, is made for you

If you're interested in understanding all the options, in order to use it to best fit your needs, you may want to jump directly to the 2nd section.

Some examples and common usages

The very first steps

Using this plugin is easy: just write

<nspages>

(You may also use the button from the toolbar.)

You will get a list of your pages displayed in columns, like this:

If you're interested in the list of the namespaces instead of the list of pages, try this:

<nspages -subns -nopages>

Pictures!

Now let's do something more colorful: if you have pictures in your pages you can do this:

<nspages -usePictures>

it will represent each page using their first picture, like this:

Tree

One last example: instead of displaying the content of a single namespace, let's display a hierarchy of pages as a tree. For the hype, let's use a whole bunch of options together (you can look at the next section in order to understand what each of those option does):

<nspages -tree -r -exclude -subns -pagesInNs -h1 -textNs="All my content as a tree!">

Bam, you get a tree like this:

This was just to get you started. This plugin is highly configurable and has a lot more features we haven't mentioned yet (other ways to display pages, to filter out some pages, to display pages with another order, …). The next section gives all the details

Manual

The general syntax is

<nspages path_to_a_namespace -option1 -option2 ...>

where:

Common 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 used 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
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. i.e. changes the “Pages in this namespace” text. Set to ="" to remove.
-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
-numberedList
display the list on a single column, as an ordered list
-simpleLine
display the list on a single line (incompatible with -simpleList)
-simpleLineBreak
display the list on a single column, separated only by line breaks (incompatible with the previous flags)
-usePictures
display the first image of each page. (Note that you can include a 1×1 pixel size image as the 1st picture on a page if you want this page to be represented by this image in a nspages TOC.)
-tree
group the items per namespaces. To be used with the -r flag. Eg:
<nspages -r -subns -nopages -tree>
-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
Less common options
-reverse
Sort the pages in reverse order
-naturalOrder
Sort the pages in natural order
-sortByDate
Sort the pages by date of last modification
-displayModificationDates
Prefix the pages by the date of their last modification
-sortByCreationDate
Sort the pages by date of creation
-pagesInNs
The pages will appear among the namespaces
-r
recurse : display the pages of the subnamespaces (if used with “-subns” it will display the sub-subnamespaces). You may use just -r to check every subnamespace, or e.g. -r=3 to have a depth limit to 3 levels
-exclude:[page1 subNs: page2]
an easier syntax to exclude several pages/subnamespaces
-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.
-pregPagesTitleOn
-pregPagesTitleOff
-pregNsTitleOn
-pregNsTitleOff
Behaves like -pregPagesOn and -pregPagesOff & Co, but filters on the title (instead of the id).
-anchorName=myName
Add anchors on each title-letters, to let link directly to them. Anchors will look like, e.g. for the letter A: nspages_myName_A
-actualTitle
print an actual html title (not just a bold and underlined text)
-actualTitle=n
print an actual html title <hn>
-idAndTitle
Use the format “id of the item - title of the item”
-nbItemsMax=n
Display at most n pages or subnamespaces
-hideNoPages
Hide page header and “no pages” message if no pages present
-hideNoSubns
Hide subnamespace header and “no subnamespace” message if no subns present
-defaultPicture
Specify the picture to display when -usePictures is used and a page doesn't contain any picture. Can be used to point at either a local file (
-defaultPicture="{{:my:picture.png}}"

) or remote one (

-defaultPicture="https://some/picture.png"

)

-showhidden
Include pages that are normally excluded from search with the hidepages config parameter. Useful for creating table of contents for hidden namespaces.
-dictionaryOrder="<locale>"
Sort according to the locale specified (see the doc). Example of usage:
-dictionaryOrder="sk_SK"
-customTitle="[{date.created}] {title} by {user}"
Use a custom format to display the title, replacing {xxx} with the associated metadata. See below for more explanations
-includeItemsInTOC
Also displays the pages in the table of contents generated by Dokuwiki (the one which appears on the top right of each page with the default template)
-sortByMetadata="date.created"
Sort the pages using the given metadata. (it can be used along with option -reverse)
-sidebar
You should use this if you use nspages to display a dynamic list of items in a sidebar. See below for more information

ex: <nspages path_to_a_namespace -exclude> or <nspages -subns -nopages> will work.

Installation

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

Option -customTitle

(Because the array above is too concise to give all the details about this option)

This option accepts a string as an argument. The name of the pages will be displayed using this format. The {xxx} part are replaced by the metadata of the page.

For instance

<nspages :my-namespace -customTitle="[{date.created}] {title} by {user}">

could display:

Some important details about this option:

Option -sidebar

DokuWiki supports sidebars out of the box.

Here is an example of sidebar generated with nspages:

To get this sidebar I just put

<nspages -simpleList -h1 -sidebar>

on the page :sidebar of my instance of DokuWiki.

The tricky part is that since I do not specify a namespace then I expect nspages to consider the namespace of the current page. But by default nspages will consider that the current page is :sidebar (because it is where it is defined), whereas want makes sense to me is that the current page is interpreted as the page that I'm currently browsing.

That's the point of the -sidebar option. In practice it:

(a consequence is that it makes no sense to both specify a namespace and have the -sidebar option, so that case will just display an error)

To put it in a nutshell: it you use nspages to generate a sidebar, then you should add the -sidebar option

Some (important) points

Charityware

nspages is a personal open source project started in 2008. I have put hundreds of hours to maintain and enhance it.

It is provided as a charityware. It can be downloaded and installed at no charge. If you found it useful and would like to support its development, you may make a donation to a non-profit charitable organization.

To who

Any NGO acting for the environment.

How

Forwarding me (address available at the top of the page) the confirmation email you send or receive will ensure your kind gesture will motivate me to continue developing this software.

I can't give money

Making sure you have a positive impact would already be awesome: