Forum
prev_url not working in pagination
I'm using Runway and have set up the following route in the admin panel for my custom blog page and Collection (I'm not using the Blog App):
/blog/page/[i:page]
And this is my pagination template:
<perch:if exists="paging">
<div class="paging">
Page <perch:content id="current_page" type="hidden" /> of <perch:content id="number_of_pages" type="hidden" /></br></br>
<perch:if exists="not_first_page">
<a class="paging-button" href="<perch:content id="prev_url" encode="false" rewrite="/blog/{page:page/%s/}" />">Previous</a>
</perch:if>
<perch:if exists="not_last_page">
<a class="cms_next paging-button" href="<perch:content id="next_url" encode="false" rewrite="/blog/{page:page/%s/}" />">Next</a>
</perch:if>
</div>
</perch:if>
The "Next" link is working fine and routes correctly to /blog/page/3
(for example). However, the "Previous" link only goes to /blog/
even when I'm viewing page 3 and above.
Any ideas where I'm going wrong?
Does
<perch:showall />
reveal anything interesting for those pages?This is shown when viewing page 3 of 3 – the URL outputted on the page for the Previous link is still simply
/blog/
.Hmm, that looks odd. Do you have any other paginated listings on the same page?
No just the one. I've used the same method for other Collection list pages (with one pagination reference only) and they also do the same thing on the previous link.
The
prev_url
works fine on default settings (without rewrites or routing in place).Also, when I was searching for a fix, this seemed like a similar issue which I replicated when removing the
rewrite
attribute from theprev_url
: https://forum.grabaperch.com/forum/01-20-2016-rewrite-rule-for-pagination-not-working-for-prev-urlUpdate: I've noticed the same issue is happening on this person's website with the previous link: https://forum.grabaperch.com/forum/05-31-2016-pagination-stopped-working https://digitaleducation.education/blog/page/4
What does it output without the rewrite?
When I remove the rewrite outputs the link to the current page on the link.
Here is the showall for this update:
I've updated my previous post above with a live example of the issue someone else has too.
Is this definitely a routed master page, and not a page out in the public folder of your site?