【问题标题】:Show how many pages in Knp pagination在 Knp 分页中显示多少页
【发布时间】:2015-05-04 19:05:33
【问题描述】:

我在 knp 分页中安装并覆盖模板。但我需要显示有多少页。例如:1 页 10、5 页 10 等等?我阅读了官方文档,但我没有找到答案。

【问题讨论】:

    标签: symfony knppaginator


    【解决方案1】:

    您可以覆盖此模板:https://github.com/KnpLabs/KnpPaginatorBundle/blob/master/Resources/views/Pagination/sliding.html.twig

    只需使用变量pageCount 来显示您想要的页面数量。

    为此,请在您的 app/Resources/KnpPaginatorBundle/views/Pagination 文件夹中创建一个 sliding.html.twig 文件。

    【讨论】:

    【解决方案2】:

    我可以在文档中看到这个抽象分页类:https://github.com/KnpLabs/knp-components/blob/master/src/Knp/Component/Pager/Pagination/AbstractPagination.php

    这个类在第113行有一个方法:

    /**
     * Get total item number available
     *
     * @return integer
     */
    public function getTotalItemCount()
    {
        return $this->totalCount;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-09
      • 1970-01-01
      • 1970-01-01
      • 2017-08-31
      • 2017-11-20
      • 1970-01-01
      相关资源
      最近更新 更多