Forum

Thread tagged as: Problem, Runway

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?

Philip Gwynne

Philip Gwynne 1 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

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/.

ID  Value
url_0   /blog/page/3
url_page    3
url_1   3
domain  https://armstrong.dev
url https://armstrong.dev/blog/page/3/
sharing_image   https://armstrong.dev/assets/img/icons/cpi-logo.png
twittername @ukCPI
perch_page_path /blog
_id 93
heading The Biopharma Challenge
_title  The Biopharma Challenge
titleSlug   the-biopharma-challenge
keywords    Biopharmaceuticals, Biopharma, global pharma, pharma market, biopharma products, biosimilars, pharmaceuticals, innovation, Centre for Process Innovation, CPI, cure diseases
desc    With the growth in biopharma treatments, find out what is holding back tailored biopharmaceutical cures for cancer and other diseases.
descPrev    With the growth in biopharma treatments, find out what is holding back tailored biopharmaceutical cures for cancer and other diseases.
postImageSocial /login/resources/blog/biopharam-header05.jpg
date    2015-10-28
hide    
noindex 
nofollow    
nosnippet   
postImageHead   /login/resources/blog/biopharam-lab.jpg
postImageCard   /login/resources/blog/biopharam-lab.jpg
blog    
Array
(
    [0] => 4
)
markets 
Array
(
    [0] => 7
)
author  
Array
(
    [0] => 64
)
_sortvalue  2015-10-28
paging  true
total   30
number_of_pages 3
total_pages 3
per_page    10
current_page    3
lower_bound 21
upper_bound 30
prev_url    /blog/page/3
next_url    
prev_page_number    2
next_page_number    
not_first_page  true
perch_item_last true
perch_item_zero_index   9
perch_item_index    10
perch_item_rev_index    1
perch_item_rev_zero_index   0
perch_item_odd  odd
perch_item_count    10
perch_namespace perch:content
Drew McLellan

Drew McLellan 2638 points
Perch Support

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 the prev_url: https://forum.grabaperch.com/forum/01-20-2016-rewrite-rule-for-pagination-not-working-for-prev-url

Update: 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

Drew McLellan

Drew McLellan 2638 points
Perch Support

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:

ID  Value
url_0   /blog/page/3
url_page    3
url_1   3
domain  https://armstrong.dev
url https://armstrong.dev/blog/page/3/
sharing_image   https://armstrong.dev/assets/img/icons/cpi-logo.png
twittername @ukCPI
perch_page_path /blog
_id 93
heading The Biopharma Challenge
_title  The Biopharma Challenge
titleSlug   the-biopharma-challenge
keywords    Biopharmaceuticals, Biopharma, global pharma, pharma market, biopharma products, biosimilars, pharmaceuticals, innovation, Centre for Process Innovation, CPI, cure diseases
desc    With the growth in biopharma treatments, find out what is holding back tailored biopharmaceutical cures for cancer and other diseases.
descPrev    With the growth in biopharma treatments, find out what is holding back tailored biopharmaceutical cures for cancer and other diseases.
intro   
The opportunity in biopharmaceuticals is huge and their increasing presence within the marketplace is impossible to ignore. With Biopharmaceuticals currently equating to around 20% of the global pharma market, they are by far the fastest growing part of the industry. But what is it that is causing this rise in demand?

postImageSocial /login/resources/blog/biopharam-header05.jpg
date    2015-10-28
hide    
noindex 
nofollow    
nosnippet   
postImageHead   /login/resources/blog/biopharam-lab.jpg
postImageCard   /login/resources/blog/biopharam-lab.jpg
blog    
Array
(
    [0] => 4
)
markets 
Array
(
    [0] => 7
)
author  
Array
(
    [0] => 64
)
_sortvalue  2015-10-28
paging  true
total   30
number_of_pages 3
total_pages 3
per_page    10
current_page    3
lower_bound 21
upper_bound 30
prev_url    /blog/page/3
next_url    
prev_page_number    2
next_page_number    
not_first_page  true
perch_item_last true
perch_item_zero_index   9
perch_item_index    10
perch_item_rev_index    1
perch_item_rev_zero_index   0
perch_item_odd  odd
perch_item_count    10
perch_namespace perch:content

I've updated my previous post above with a live example of the issue someone else has too.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is this definitely a routed master page, and not a page out in the public folder of your site?