How to go to the last pagination page in CakePHP 3 -


in cakephp 1.3 go last pagination page adding parameter page:last.

i tried use ?page=last in cakephp 3.0 not work. how can accomplish this?

the functionality mention removed in cakephp 2.0.

in cakephp 3.x, create link within view, can call

$this->paginator->last($last = 'last >>', $options =[]) 

to obtain last page within controller, can access following property:

$this->request->params['paging']['pagecount'] 

edit

a possible workaround accept page:last add following @ beginning of action:

public function index() {     // detect page:last     if (!empty($this->request->params['named']['page'] && @$this->request->params['named']['page']=='last')) {         $this->paginator->paginate();         $this->request->params['named']['page']=$this->request['paging'][$this->modelclass]['pagecount'];     }      //rest of code action      $this->set('results', $this->paginator->paginate()); } 

you have call $this->paginate() twice, it's not ideal.


option perhaps extend lib/cake/controller/component/paginatorcomponent.php supports page:last. further information, see


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -