Sort sub-pages of current page by SORT page variable then by alpha.
| Name | Type | Default | Description |
|---|---|---|---|
| sortPath | incoming | nil | Page path to display subPages from - default is current page. This is an optional parameter. |
PageSort(sortPath:any):html
This will sort the sub-pages of the page found at the path specified by the optional parameter sortPath in alphabetical order. If sortPath has not been specified, then the sub-pages of the current page will be sorted in alphabetical order.
If there is a requirement to sort the sub-pages differently, for example if you have sub-pages like "Introduction", "Getting Started" and "Advanced Concepts", and you want them to appear in that order, you would need to set the page properties on each page to the named property "SORT" with ascending numerical values on each page, e.g. "10", "20", "30". I would recommend using multiples of 10 as you never know when you might want to add another page within the existing sort order. To see how to set page properties see Set_Page_Properties.
Bulleted list of sub-pages (one level deep) as links, sorted by SORT property (numerical) against each page and then by alpha.
| Output | |
{{PageSort()}} | |
{{PageSort("en/docs/DekiScript/Reference/")}} |
// aleggett with assistance from SteveB, neilw & rberinger 10.05.2010
// get the initial list of pages
var sortPath = $0 ?? $sortPath ?? _;
var subPageList = [];
if (sortPath == _){
let subPageList = map.values(page.subpages);
} else {
let subPageList = map.values(wiki.getPage(sortPath).subpages);
};
// sort by SORT property and/or by alpha
var plist = list.sort{list:subPageList, compare:"(
var L = num.cast($left.properties['SORT'].text);
var R = num.cast($right.properties['SORT'].text);
(L && R) ? (L - R) : string.compare($left.title, $right.title, true)
)"};
// show the pages
foreach (var p in plist){
<ul><li>web.link(p.uri,p.title);</li></ul>;
};
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by