Limit Number of Pages Displayed with Pagination
Permalink
Hi there,
I'm using Pagination within one of my page types and I'd like to limit the number of pages it renders with the following code: <?php echo $paginator->getPages(); ?>
Right now, I have my page list set to display 5 items per page. I have 35 items, and therefore my pagination looks something like so:
Prev [1] 2 3 4 5 6 7 Next
(the brackets around the 1 represent the active page)
I'd like to limit the pagination to only display 5 pages at a time. So that it looks something like so:
Prev [1] 2 3 4 5 Next
And if you were on page 5, it would look something like so:
Prev 3 4 [5] 6 7 Next
And so on. It doesn't need to work exactly like this. My main concern is just limiting the amount of pages that get output by $paginator->getPages();
I've searched high and low but I can't find any information on how to achieve this. Can anyone help me out?
Thanks!
I'm using Pagination within one of my page types and I'd like to limit the number of pages it renders with the following code: <?php echo $paginator->getPages(); ?>
Right now, I have my page list set to display 5 items per page. I have 35 items, and therefore my pagination looks something like so:
Prev [1] 2 3 4 5 6 7 Next
(the brackets around the 1 represent the active page)
I'd like to limit the pagination to only display 5 pages at a time. So that it looks something like so:
Prev [1] 2 3 4 5 Next
And if you were on page 5, it would look something like so:
Prev 3 4 [5] 6 7 Next
And so on. It doesn't need to work exactly like this. My main concern is just limiting the amount of pages that get output by $paginator->getPages();
I've searched high and low but I can't find any information on how to achieve this. Can anyone help me out?
Thanks!
![roketto](/files/avatars/19897.jpg)
No one has any ideas on how to achieve this?
The default behavior in page_list block is to show 5 item before and after the current page, plus first and last pages. to change this 5, simply replace 5 to another number at:
\concrete\core\helpers\pagination.php: function getPages (line 200 & line 215)
\concrete\core\helpers\pagination.php: function getPages (line 200 & line 215)
The code that generates this page section is found in /concrete/core/helpers/pagination.php the getPages() function.
I needed to do this the other day, so created: pagination.php in th e/helpers folder.
I've just added the variable to the function for $pagesEitherSide, and changed where 5 (the default value) existed to this variable.
However you will need to call the getPages with getPages('span', NUMBER_OF_PAGES), as it is the second argument.
I needed to do this the other day, so created: pagination.php in th e/helpers folder.
<?php defined('C5_EXECUTE') or die("Access Denied."); /** * Class to paginate record sets. * @package Helpers * @category Concrete * @author Tony Trupp <tony@concrete5.org> * @copyright Copyright (c) 2003-2008 Concrete5. (http://www.concrete5.org) * @license http://www.concrete5.org/license/... MIT License */ class PaginationHelper extends Concrete5_Helper_Pagination { function getPages($wrapper='span', $pagesEitherSide=5){ if($this->number_of_pages==1) return; $pages_made=0; for ($i=0;$i<$this->number_of_pages;$i++){ //preceeding dots for high number of pages
Viewing 15 lines of 58 lines. View entire code block.
I've just added the variable to the function for $pagesEitherSide, and changed where 5 (the default value) existed to this variable.
However you will need to call the getPages with getPages('span', NUMBER_OF_PAGES), as it is the second argument.
ADZ - Your code actually worked. But this definitely isn't an exact copy of what is in the core's pagingation.php file. Did you just write this yourself?
EDIT - I just noticed the code only half works. If the user starts navigating with the prev/next links in the navigation the numbers will return to the default amount when the page reloads.
Thanks
EDIT - I just noticed the code only half works. If the user starts navigating with the prev/next links in the navigation the numbers will return to the default amount when the page reloads.
Thanks
A year later, I'm still trying to do this without success. I can edit the file in the core, but I get an error it I make a copy and place it into the /helpers/ folder.
Anyone know why?
Anyone know why?