How can i set pagination limit globally

How can i set pagination limit globally.

What version of CakePHP?

I’m still using v2 for an app I develop, but in the AppController.php I’d imagine you’d add something like

	$this->Paginator->settings['limit'] = '25';

in the paginate public function.

I’ve not migrated to CakePHP 3 yet but just did a quick test - stick this in the AppController

public $helpers = [
          'Paginator' => ['templates' => 'paginator-templates']
      ];
      public $paginate = [
       'limit' =>5
   ];

Hope that helps

Brian

1 Like

I dont know if this is the best solution but you can set a global variable in bootstrap.php for ex: define(‘PAGINATOR_LIMIT’, 25);
and in the controller you want set:
$this->paginate = [
‘limit’=>PAGINATOR_LIMIT,
];

1 Like

Ok, Thanks For reply, I will check it.