l3nox
l3nox

Reputation: 15

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? 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. Is there any other way?

Upvotes: 0

Views: 52

Answers (1)

Exterminator
Exterminator

Reputation: 1246

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

Upvotes: 1

Related Questions