-
- 53 Posts
Hi,
I’m working on a website for a local charity and the site contains a page for each of the projects they are working on.
So for example there is a parent document called Africa with all their Africa projects listed as children beneath it.
They would like to add previous and next project links to each project page so it’s easy for users to move from one to the other. Is there an easy way to generate these dynamically rather than having to update them manually when projects are added or removed?
Thanks for looking.
-
- 209 Posts
No, there is no easy way to generate such links. In order to navigate through documents we need to know their ids. Ids can be retrieved "from the point of view" of the parent of your projects (document Africa). Possible snippet for generating your links should behave the following way:
1) get the id for the parent of the current document (project);
2) get ids for all children of the parent (retrieved in step 1);
3) render links for all children’s ids except the current document (the page on which the snippet currently operates).
This algorithm makes links for all sibling projects.
Generating specifically "Next" and "Previous" links is a bit more sophisticated because all children should be ordered in some way (to give a sense for "next"/"previous" terms) - value of the document’s field "Menu index" is a good way for such an ordering.
-
- 53 Posts
Thanks David.
PrevJumpNext did the job perfectly.
http://modxcms.com/PrevJumpNext-831.html