Forum

Thread tagged as: Question, Problem, Configuration

Pagination previous link not working

Hey,

I'm using the standard snippet for pagination - for some reason the Previous link doesn't work - just wondering if anyone could help?

<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>
Dan Temple

Dan Temple 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

In what way doesn't it work?

There's no url...

<a href>Previous</a>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you using the standard ?page=2 format?

Yep

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show me the debug from the page where it's not working?

SELECT collectionID, collectionTemplate FROM perch2_collections WHERE collectionKey='Jobs'SELECT SQL_CALC_FOUND_ROWS DISTINCT * FROM ( SELECT idx.itemID, ci.collectionID, ci.itemJSON, idx2.indexValue as sortval FROM perch2_collection_index idx JOIN perch2_collection_items ci ON idx.itemID=ci.itemID AND idx.itemRev=ci.itemRev AND idx.collectionID=ci.collectionID JOIN perch2_collection_revisions cr ON idx.itemID=cr.itemID AND idx.itemRev=cr.itemRev AND idx.collectionID=ci.collectionID JOIN perch2_collection_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_id' WHERE (idx.collectionID=1) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID ORDER BY sortval * 1 DESC LIMIT 8, 8

SELECT FOUND_ROWS() AS `count` 

Using template: /templates/content/_job_list.html

This is from page 2

Drew McLellan

Drew McLellan 2638 points
Perch Support

That's all of it? No routing information?

No, doesn't seem to be?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you using routing?

No, this is just a standard Perch site

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ah ok. Can you show me the options you're using?

perch_collection('Jobs', array(
                    'page'=>'/view-job.php',
                    'template'=>'_job_list.html',                   
                    'sort' => '_id',
                    'sort-type' => 'numeric',
                    'sort-order' => 'DESC',
                    'paginate' => 'true',
                    'count'=>'8'
                )); 
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can't use perch_collection() on a standard Perch site.

Sorry Drew, I'm getting my sites mixed up :-s

This is a Perch Runway site, upgraded from a basic Perch site. I can't actually remember if this ever used to work.

Drew McLellan

Drew McLellan 2638 points
Perch Support

SO you can move forward through pages, but not back?

Yes, moving forward works ok - just can't go back using the prev link.

I'm having the same problem! I'm using the default pagination template, which looks like like Dan's above.

When I run <perch:showall/>, I see that the prev_url variable is unset. I'm also using the standard ?page=1 format.

By the way, I was able to find a workaround by using prev_page_number like this:

<a href="?page=<perch:content id="prev_page_number" type="hidden" encode="false" />">Previous</a>

That also worked for the blog pagination

<a href="?page=<perch:blog id="prev_page_number" type="hidden" encode="false" />">Previous</a>