Forum

Thread tagged as: Question

"Variable" Pagination

Hi Drew,

I've set up a region on a page with the content currently paginating after every 4 items, is there a way that I can make this setting available to the admin or do I have to have multiple versions of the template with the pagination set to different values?

Nick Loat

Nick Loat 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you could store it as content - or maybe as a page attribute.

Hi Drew,

I've set up a page attribute (pagination.html) which consists of a select list returning a number 1-10 which will equal the count (of items) to be displayed on each paginated page.

what I'm unclear about is how to pass this value into the page template? Currently the page uses…

   <?php perch_content_custom('Content', array (
   'paginate' => true,
   'count' => 4,
   )); ?>

to paginate the content of the region "Content" …how do ! get 'count' to use the value generated from my page attribure?

Drew McLellan

Drew McLellan 2638 points
Perch Support

perch_content_custom('Content', array (
   'paginate' => true,
   'count' => perch_page_attribute('count', true),
   )); 

Hi Drew,

It doesn't appear to be passing the the value of 'count' as a parameter of the perch_content_custom function,

But instead is inserting it just after the <body> tag (so it shows up as a number at the top of the page.)

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ah, sorry:

'count' => perch_page_attribute('count', [], true),

Perfect, many thanks Drew.