Forum

Thread tagged as: Problem, Runway

Collection Pagination Problem

Greetings, it's Nick and I'm back again about that jewelry site... I discovered that the pagination of my "Rings" Collection is not working properly.

Here is my Collection call:

$categories = array();
if (perch_get('collection')) { $categories[] = 'collection/' . perch_get('collection'); }
if (perch_get('style')) { $categories[] = 'style/' . perch_get('style'); }
if (perch_get('type')) { $categories[] = 'type/' . perch_get('type'); }

perch_collection('Rings', array(
    'category' => $categories,
    'category-match' => 'all',
    'template' => 'rings.html',
    'count' => 24,
    'paginate' => true,
));

And here is my pagination code in the rings.html template

<perch:if exists="paging">

    <div class="container">
        <div class="paging">
          <span class="page-of">Page <perch:content id="current_page" type="hidden" /> of <perch:content id="number_of_pages" type="hidden" /></span>
          <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" type="hidden" />
          <perch:if exists="not_last_page">
            <a href="<perch:content id="next_url" type="hidden" encode="false" />">Next</a>
          </perch:if>
        </div>
    </div>

  </perch:if>

What is happening is that when I select the "next" link, it will go to "page=2" but the query string from the original call will not persist. The only query string is now "?page=2". Furthermore, when I select "next" again, it will only repeat the "?page=2" string. When I select the "Previous" link, it once again stays on page 2.

I brought up the copy of this site I still have built with regular Perch and the pagination works perfectly. The query string persists and all.

I'm sorry, this is a terrible weekend to have trouble I know! Thank you very kindly for help!

Nicholas Nelson

Nicholas Nelson 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Which version are you running? Is it up to date?

Perch is out of date. You are running Perch Runway 2.7.3 and the latest is 2.7.4

I'll give that a shot!

Ok, just updated but the problem is not resolved.

The original query string does not persist. The "next" link will will add to "page=2", but the "previous" link still remains on the same page.

Should I be rolling my own pagination links and passing them into my template? If I use the same collection call but store it in a php variable, is there a key that will tell me how many pages of items there are? The other option I can think of is to do math with the number of items returned and number of items I would like per page.

I found $collArray[0]["number_of_pages"] and have a system that seems to work for now. It wont work with 'page-links' => true, though. I would like to add all page links in the future.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'll see if I can reproduce it.