Concrete5 Pagination - Limit Number of Pages Being Output

微笑、不失礼 提交于 2019-12-11 05:51:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!