简体   繁体   English

Cakephp 3.6分页器

[英]Cakephp 3.6 paginator

is there any way for the paginator in index.ctp to be displayed only if there are more than 20 records? 仅当记录超过20条时,才可以显示index.ctp中的分页器吗? Now, if in my table there aren't records, the paginator is displayed anyway, and it looks very bad. 现在,如果在我的表中没有记录,则无论如何都会显示分页器,它看起来非常糟糕。

I was thinking about using if condition, that if the length of the array is bigger than 20, so the paginator displays, but I would have to give it to every view. 我在考虑使用if条件,即如果数组的长度大于20,则将显示分页器,但我必须将其赋予每个视图。 Is there any other way? 还有其他办法吗?

You can check using the following condition 您可以使用以下条件进行检查

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.

for more details check this link Checking the Pagination State 有关更多详细信息,请单击此链接检查分页状态

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM