Forum

Thread tagged as: Question

Paginating filtered content...

OK, so I have a checkbox on my form to mark items as 'sold'. I want to list all items on the same page but with the sold items at the bottom under a separate heading of 'Recently Sold'. I have done this, but I also want to paginate the entire thing. As it is, I have set up two different sections on the page as such:

perch_content_custom('Cars for Sale', array(
          'template' => 'car_listing.html', 
    'filter' => 'sold',
    'match' => 'neq',
    'sort-order' => 'DEC',
     'value' => 'yes',
     )); 
        ?><hr/> <h2>Recently Sold</h2> <?php
    perch_content_custom('Cars for Sale', array(
          'template' => 'car_listing.html', 
    'filter' => 'sold',
    'match' => 'eq',
    'sort-order' => 'DEC',
     'value' => 'yes',
     ));

Now, if I add pagination here it will do it twice - how can I combine all the data so I can paginate it, but also separate it based on the checkbox value? Is it do-able?

Lisa Morena

Lisa Morena 1 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Could you not sort it by the sold field so they're all grouped together at the end?

This line is incorrect and isn't doing anything:

'sort-order' => 'DEC',

But how would I add in the subheading before the sold items?

Drew McLellan

Drew McLellan 2638 points
Perch Support

With:

<perch:if different="sold">... your heading ...</perch:if>

And that would then show once above all the recently sold items?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, did you try it?

No, I wasn't in the office - will try now.

It does, but then it sorts them so that the newest added item for sale or most recently sold is at the bottom.

Ah, OK so if I don't sort on sold, it does it perfectly for me - the sold items are all moved to below the for sale items manually anyway so no need to sort on that.

Thanks Drew