IndentedPageList

Summary:Sort and indent pagelist items using page text variable
Version:
Prerequisites:
Status: tested
Maintainer: Jiri
Categories: PageList

Questions answered by this recipe

This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer. How to indent pagelist items according to the listed documents hierarchy

Description

Sort and indent pagelist items according to the listed documents hierarchy.

When listing pages of some documentation not by Name nor by Title sorting is always suitable.
More I wish to indent the listed titles like in the multilevel bulleted list.

Solution:
Put in your documents page text variable e.g. docnum by this example:

docnum valuein the page with the title
0Introduction
1System requirements
11Hardware
12Other parties software
2Installation
3Implementation
4Users manual - by roles
41Administrator
42Management
43Sales dpt.
etc.
How to:
(:title Introduction:)
(:docnum:0:)

etc.

The pagelist should look like this:

 Introduction
 System requirements
    Hardware
    Other parties software
 Installation 
 Implementation
 Users manual - by roles
    Administrator
    Management
    Sales dpt.

You can get it by sorting the pagelist

 sort=$:docnum 

and in the format using the markup (:indent =$:<PTVname>:) which Caveman kindly created for me.
Just put the following lines into your local/config.php

# usage: (:indent =$:<PTVname>:)
# indents text with groups of spaces - number of groups is given by PTV length
Markup('zapindent', 'inline', '/\(:indent (.*?)\:\)/e', 'ZAPindent("$1")');
function ZAPindent($x) {
	$x = trim($x);
	for ($i = 0; $i < strlen($x); $i++) {
		$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	}
	return $out;
}

example:

(:pagelist group=MyManual $:docnum=?* sort=$:docnum  fmt=#fmtIndented:)

(:if false:)
[[#fmtIndented]]
(:indent =$:docnum:){=$Title}
[[#fmtIndentedend]]
(:ifend:)

Thus the level 1 document is indented with 5 spaces, level 2 with 10 spaces.

You can replace the $out variable assignement

$out .= "*";

to get bulleted list of proper levels.

Notes

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See Also

Contributors

Comments

See discussion at IndentedPageList-Talk?