I have trouble getting the prev() page navigation to work on my website. I want to link back from a product page to it’s parent – which is also a sub-page of a overview page.
Does prev() not work for su-page or am I just not getting it?
Thank you – and let me know if you’d need more info,
Linus
$page->prev() always works in relation to the current page, i.e. within the siblings of the current page. Since parents or children are not siblings of the current page, they are not taken into account.
To cycle between pages of a given collection, you could use the getPrev() and getNext() custom methods from my pagemethods repo. They calculate the prev/next pages based on the collection you pass to the method as parameter.
I simplycreated a page-methods folder with an index.php file and pasted your code snippet.
After that I created a link on the page where I want to add the “Previous” page with: