I'm developing pages in AEM 6.3. Right now I have a situation to develop a page containing 2 links that browse to next and previous page with respective to current page. Let's say I have 3 pages under my project site /content/project/en.
- Page A
- Page B
- Page C
Let's assume, if I'm on Page B, then my next page should be Page C and previous page should be Page A. Those two links(next/previous) should redirect me to Page A and Page B.
There might be many approaches to do that but what I have in mind is that, I'll be making an ajax get request which will return me next and previous pages in key/value format. To do this I'll be using sling servlet object to get the page path and query builder to make query on that path to get the next and previous page. This approach works fine if there is very limited number of pages but would be time consuming if pages increases.
I want simple solution to implement this. Or is there any plugin in aem to do this? I also tried to do that with currentPage.nextSibling() in sightly but there is no such thing exist in aem.
listChildren()
would be faster than querying in this case, as you are listing only the first level children. See when to use JCR queries outlined in the best practices. – rakhi4110