문제

Is there any way to set the maximum number of result or pages in cakephp pagination? I know I can get number of pages running

$this->params['paging'][<MODEL NAME>]['pageCount']
도움이 되었습니까?

해결책

You may not set pageCount in cakephp pagination. I am not sure about that.

You can only get the counts in controller as well as in the CTP files: Let model is "Client" then

In Controller:

$clients = $this->paginate('Client');
print_r($this->params['paging']['Client']);

In cakephp templates:

$counts = $this->Paginator->params();
print_r($counts);

out put:

Array
 (
[page] => 1
[current] => 20
[count] => 144
[prevPage] => 
[nextPage] => 1
[pageCount] => 8
 )

Removed the unnecessary elements from the out put array.

다른 팁

yeah you can do that in your controller, you can put this variable

public $paginate = array(
    '<MODEL NAME>' => array (
        'limit' => 10, //limit is number of rows per page
//... other condition here
        )
    );
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top