سؤال

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