问题
This question is directly related to Concrete5 CMS.
I'm using the built in Pagination helper in 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(); ?>
Here's the entire code I'm using in the template:
if ($paginate && $num > 0 && is_object($pl)): ?>
<div class="pagination">
<?php
$summary = $pl->getSummary();
if ($summary->pages > 1):
$paginator = $pl->getPagination();
?>
<span class="page-prev"><?php echo $paginator->getPrevious('Prev'); ?></span>
<span class="pages"><?php echo $paginator->getPages(); ?></span>
<span class="page-next"><?php echo $paginator->getNext('Next'); ?></span>
<?php endif; ?>
</div>
endif;
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?
回答1:
The answer for me was changing value of $proximity number. Number defines number of page numbers showed next to active page number. Code example in my view.php
<div class="ccm-pagination-outer-wrapper">
<?php
$showPagination = true;
$options = array(
'prev_message' => t('← Previous page'),
'next_message' => t('Next page →'),
'proximity' => 0
);
echo $pagination->renderDefaultView($options);
?>
</div>
来源:https://stackoverflow.com/questions/15142855/concrete5-pagination-limit-number-of-pages-being-output