Find out how many pages of results there are in a paginated CakePHP controller

I am using the CakePHP paginate method in the controller. I want to know how many pages of results have been created. It is quite simple in the view ( $paginator->counter() ), but I would like to access this information from the controller itself. Any ideas?

+4
source share
3 answers
 $this->params['paging'][<MODEL NAME>]['pageCount'] 

try using this. I think you need

+11
source

A bit of searching bought this

 $this->params['paging'][$model]['count'] 

Where $model is your model name.

http://whilefalse.net/2010/11/09/cakephp-get-paginator-count-controller/

+3
source

In CakePHP 3, you can access the parameters as follows after calling the paginate () method.

 $this->request->params['paging']['Model'] 
+2
source

Source: https://habr.com/ru/post/1346713/


All Articles