// PreviousNextLinks: display links to "previous" and "next" wiki page
//
// Original by lktest, March 2009
//
// Updated by neilw, 10/19/2009
// This is just a starting point, still needs fine-tuning, especially w/regard to presentation of the links.
var allowed_keys = [ "name", "title", "id", "uri", "update", "create" ];
// Process args
var sortKey = $0 ?? $key ?? "title";
var sortOrder = $1 ?? $order ?? false;
// Validate sortKey
if (sortKey is not str || !list.contains(allowed_keys, string.tolower(sortKey))) {
<span style="font-weight:bold; color:red"> "ERROR: invalid sortkey: "; sortKey; </span>; <br />;
let sortKey = "title";
}
// Sort the list of pages
var pages = [
{ name:p.name, title:p.title, id:p.id, uri:p.uri,
update:date.format(p.date,"s"), create:date.format(p.revisions[0].date,"s") }
foreach var p in page.parent.subpages ];
let pages = list.sort(pages, sortKey, sortOrder);
// Find my current position on the list
var position = list.indexof(list.collect(pages, "id"), page.id);
// Display "previous" link
if (position > 0) {
"Previous: ";
web.link(pages[position-1].uri, pages[position-1].title);
<br />;
}
// Display "next" link
if (position+1 < #pages) {
"Next: ";
web.link(pages[position+1].uri, pages[position+1].title);
}
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by