如何将cakephp3默认分页限制更改为20到100

时间:2018-12-31 13:45:36

标签: cakephp cakephp-3.0

如何将Cakephp3的默认分页限制从20更改为100

cakephp的新手是任何人,请指导我,现在如何设置默认限制为20,但我要100

1 个答案:

答案 0 :(得分:0)

xxxxxcontroller.php

将以下代码添加到您的控制器

 public $helpers = [
           'Paginator' => ['templates' => 'paginator-templates']
       ];
       public $paginate = [
        'limit' =>100
    ];
    public function index() 
    {       
            $users = $this->Users->find('all');     
            $users=  $this->set('users', $this->paginate());
     }

您可以将limit的值调整为所需的任何数字。就像您要将limit的值更改为100一样

index.ctp

<?= $this->Paginator->first("First");   ?>
  <?= $this->Paginator->prev('< ' . __('Previous')) ?> 
  <?= $this->Paginator->numbers();  ?>   

           <?= $this->Paginator->next(__('Next') . ' >') ?> 
           <?= $this->Paginator->last("Last"); ?>
        </ul>
 <p>Showing <?= $this->Paginator->counter() ?></p>