Forum

Thread tagged as: Problem

prev_url not working

Hello,

I've just added pagination to a perch_collection, using the standard pagination snippet. It seems like quite a few other people, I have run into the issue of prev_url not working.

next_url works fine, but prev_url does not. If I output <perch:showall /> then prev_url shows as blank

My issue is pretty much identical to this one, which was never solved: https://forum.grabaperch.com/forum/02-04-2015-pagination-previous-link-not-working

I am up to date on Perch Runway version 3.0.8, PHP 7.0.8 is up to date, MySQL 5.5.42 is up to date I'm not using any routing or anything fancy; just Runway out of the box.

Here is my code just in case it helps:

<?php perch_collection('Galleries', [
    'count'     => 4,
    'paginate'  => true,
    'template'  => 'galleries/gallery_listing.html',
]); ?>

I'm using the standard pagination template as follows:

<perch:after>
  <perch:if exists="paging">
    <div class="paging">
      Page <perch:content id="current_page" type="hidden" /> 
        of <perch:content id="number_of_pages" type="hidden" />
      <perch:if exists="not_first_page">
        <a href="<perch:content id="prev_url" type="hidden" encode="false" />">Previous</a>
      </perch:if>
      <perch:content id="page_links" encode="false" />
      <perch:if exists="not_last_page">
        <a href="<perch:content id="next_url" type="hidden" encode="false" />">Next</a>
      </perch:if>
    </div>
  </perch:if>
</perch:after>
Jay George

Jay George 2 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Routing isn't fancy - it's a basic feature of the software you're using. Does the pagination work if the page is correctly routed?

Hmm yes actually.

I haven't used routing before now, instead I've just placed the file in the root as I used to with standard perch. It seems like the file needs to run through the front-controller pattern for pagination to work i.e. it needs to be a master template.