, (*1)
Installation
You can install this plugin into your CakePHP application using composer., (*2)
The recommended way to install composer packages is:, (*3)
composer require brenoroosevelt/cakephp-pagination-cache
Load the plugin
Add following to your config/bootstrap.php
, (*4)
Plugin::load('BRPaginationCache');
Usage
Controller class
public function index()
{
// load component with setup param
$this->loadComponent('BRPaginationCache.PaginationCache', [
'session' => 'posts_pagination'
]);
// restore pagination from session
$this->PaginationCache->restore();
// pagination
$this->set('posts', $this->paginate($this->Posts));
// save pagination from session
$this->PaginationCache->save();
}
All params are persisted using sessions. Make sure to load the Session component., (*5)