Forum
List and Detail page - how can I add a link to next and previous item of list in...
Have implemented the list and detail page from Solutions > Architecture... On the detail page I am wanting to add links "Back" and "Next" to other items in the list. (Currently these links are inside the template). Thought I could use "prev_url" / "next_url" but only populates these as current URL?
prev_url
andnext_url
are used in list pagination. You're showing a list of one when you show a detail page.You can use
perch_content_custom()
to filter for the previous and next items. What field are you sorting by?Filtering by slug... just using the standard example code with our templates:
Which field are you sorting by when you consider previous and next items?
Have not specified a sort order or ID, so assume it's the default order of items in the region. Should we add an ID to sort by? Would be "title" in that case.
Is there not an ID we can use of the order of the item in region?
Will we need to pull these links to prev/next outside of the html template and into PHP?
I'll see if I can put an example together.
OK thanks, that would be awesome.
I've written it up here: https://solutions.grabaperch.com/architecture/how-do-i-link-prev-next
Thanks! You guys rock!! Will give it a whirl later today and let you know how we go.
Added this in and it works perfectly, thanks again. You guys give amazing support!
No problem!
Hi Drew I have followed these instructions but I keep getting the following PHP error:
PHP Warning: Illegal string offset '_sortvalue' in C:\Websites\kendalls\public-media-relations.php on line 91
Using the very latest version of perch.
Apologies I have fixed that issue, simple typo!
However is there an easy way of getting to go back to the beginning item when it has gone through all of the items. So it just keeps going back to the beginning item after the last item?