Version 10.1 by Jerome on 2010/12/07 11:20
Warning: For security reasons, the document is displayed in restricted mode as it is not the current version. There may be differences and errors due to this.

cog
TypePlugin
Category
Developed byUnknown
Rating
0 Votes
LicenseUnknown

Description

The Sorted Document Tree Plugin creates a hierarchical link list of all pages in the current space and it allows to specify the position of each page in the list. In the list there are only pages that are either parents of other pages or children of other pages (so there must be some relationship between them).

Installation

  1. Copy the jar archive into %xwikipath%/WEB-INF/lib/
  2. Add com.xpn.xwiki.plugin.SortedTree.SortedTree to xwiki.cfg
  3. Import all XWiki pages from the xar archive to your XWiki

How to use it

You need to call one method of the plugin called index() which has 4 parameters. 

For example Failed to execute the [velocity] macro. Cause: [Nested scripts are not allowed. Current Script Macro [velocity] (source [extensions:ExtensionCode.ExtensionSheet]) is executed inside Script Macro [velocity] (source [extensions:ExtensionCode.ExtensionSheet])]. Click on this message for details.

  • The first parameter specifies the space which is supposed to be searched
  • The second parameter specifies the current user (because each user is able to see only pages on which he has "view" rights )
  • The third specifies Max depth for searching
  • The fourth parameter is used for changing the order of the list

Changing the list order

If you want to have some page higher (or lower...) in the list than others you must specify the page's weight. There are two ways to do that:

  • use XWiki class XWiki.TagClass (instances are added to all pages by default)
  • or use imported class (section Installation step 3) called XWiki.SortedTreePageClass

Usage of these 2 classes is very similar. If you use TagClass, just add some integer value to the tag attribute. But this attribute must contain only this number. If you use this class for other purposes, you can use SortedTreePageClass. This class has only one attribute called weight. Again, to use it just add an instance of this class to your page and put some integer into the attribute.

Generally, the lower the weight (specify in instance of TagClass or SortedTreePageClass) is, the higher the page in the list is. Common values are between 1 to "infinity" (I recommend 1 to 100). If the page doesn't have weight (or there was a problem with it), then its weight is considered to be 50 (that is the reason I recommend 100 as maximum). 

However there are some special values:

  • if the weight starts with 0, then child pages are not included in the list, but the parent page is. For example page A has weight 025 and this page has some child page B. Then this page B is not in the list (and also all children of B are not in the list) but page A is included in the list and its weight is considered to be 25
  • if the weight is less then 0, then this page is not in the list and also all it's children (and children of them...) are not in the list. So this could be used to exclude some pages from the list

Example

In the page you want to see this list type:

$xwiki.sortedTree.index($doc.space, $context.user,4,0)

And the result looks like this:

screen.png

Get Connected