Is using followingSibling and preceedingSibling for Next and Previous, after using SortTool possible?

lizhunter's Avatar


18 Aug, 2014 08:11 PM

I read about how to set up a Next and Previous links using velocity that gets the previous and next siblings (followingSibling and preceedingSibling). I can definitely get that to work but I'm wondering if it's possible to get the next and previous items AFTER the sort tool is used to sort items by Start Date so even if the items are entered in the wrong order they will be sorted correctly by date for the previous and next siblings. I have tried this and it seems to sort from the original (or actual) system page order rather than by the date. I have a very simple setup where the assets are a list of pages in one folder.

  1. 1 Posted by Ryan Griffith on 19 Aug, 2014 06:21 PM

    Ryan Griffith's Avatar

    Hi Liz,

    This should be doable since the variable containing the elements being sorted is updated when you call the sort method. When you have a moment, please attach your Velocity Format and I would be happy to help take a look.


  2. 2 Posted by lizhunter on 19 Aug, 2014 10:11 PM

    lizhunter's Avatar

    Hi Ryan. In the velocity format attached here (with the xml) you can see that when I use other tools the articles are sorted correctly (by date) but when I use the XPathTool to get the preceding-sibling or next sibling, the paths being pulled are in order by the system order, rather than by the "start-date". I have the system names for the pages set to be the year and month, so 1407 = July 2014. In my example for testing, I see, for example that I use "1407" for a preview, the previous is 1301, and the next is 1406, which is the order they are in in the system. I feel like it's not working because I have to get the previous and next from the current page and the sort order is by the pages.

  3. 3 Posted by Ryan Griffith on 20 Aug, 2014 12:24 PM

    Ryan Griffith's Avatar

    Thank you for the additional information and the sample files, Liz.

    You are definitely correct in that the original JDOM Element structure doesn't seem to change when using the XPath Tool. With that, I think you will be better off accessing the sorted Array's indexes instead. I've attached an updated Format that I believe should do the trick.

    Please let me know how the new Format works out, or if you have any questions.


  4. Ryan Griffith closed this discussion on 03 Sep, 2014 07:54 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac