简体   繁体   中英

How to change cakephp3 default pagination limit 20 to 100

How to change cakephp3 default pagination limit 20 to 100

Am new to cakephp anyone please guide me, how to set default limit now is 20, but i want 100

xxxxxcontroller.php

add code below to your controller

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

You can adjust the value of limit to any number you want. Like for the one you wanted change the value of limit to 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM