【问题标题】:Cakephp 3.6 paginatorCakephp 3.6 分页器
【发布时间】:2018-09-07 18:02:36
【问题描述】:

有没有办法让 index.ctp 中的分页器只有在超过 20 条记录时才显示? 现在,如果在我的表中没有记录,则无论如何都会显示分页器,并且看起来很糟糕。

我正在考虑使用 if 条件,如果数组的长度大于 20,则显示分页器,但我必须将其提供给每个视图。有没有其他办法?

【问题讨论】:

    标签: php cakephp conditional-statements cakephp-3.x paginator


    【解决方案1】:

    您可以使用以下条件进行检查

    Cake\View\Helper\PaginatorHelper::hasNext(string $model = null)
    Returns true if the given result set is not at the last page.
    
    Cake\View\Helper\PaginatorHelper::hasPrev(string $model = null)
    Returns true if the given result set is not at the first page.
    
    Cake\View\Helper\PaginatorHelper::hasPage(string $model = null, integer $page = 1)
    Returns true if the given result set has the page number given by $page.
    
    Cake\View\Helper\PaginatorHelper::total(string $model = null)
    Returns the total number of pages for the provided model.
    

    更多详情请查看此链接Checking the Pagination State

    【讨论】:

    • 谢谢!这对我有帮助
    猜你喜欢
    • 1970-01-01
    • 2014-02-20
    • 1970-01-01
    • 2019-02-18
    • 2019-01-04
    • 2014-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多