I have done a search on the XWiki Extensions, but I could not find anything similar to my “request”.
Imagine a structure like:
Parent
I would like to have a button/link on each child page to the “next” and “previous” page. It should basicly look one step back (to the parent), and then to the next or previous page (based upon the name of the page, in alphabetic order).
Has anyone created such a thing???
I’m going to try something with Velocity…
- Get Parent of current doc
- Loop all child pages of parent, “searching” for the current doc, getting that index
- Add 1 or Substract 1 from that index
- Create links to those documents (Next and Previous)
4a) If the index = 0 or index = last_index, than Next or Previous will be disabled, OR Next page goes to first document and Previous goes to last document.
Wish me luck
Thanks!
I could not have done this without your support
Here’s my very primitive code, please use with caution
{{velocity}}
#set($parent = $doc.parent)
#set($page_next = $doc.parent)
#set($page_previous = $doc.parent)
#set($page_found = 0)
#set($where = "where doc.parent = '$parent' order by doc.name")
#foreach($name in $xwiki.searchDocuments($where))
#if ($page_found == 1)
#set($page_next = $name)
#break
#end
#if ($name == $doc)
#set($page_found = 1)
#end
#if ($page_found == 0)
#set($page_previous = $name)
#end
#end
[[Previous Page>>$page_previous]] - [[Parent>>$parent]] - [[Next Page>>$page_next]]
{{/velocity}}