Converting named parameters to GET parameters for pagination at CakePHP 2.2

百般思念 提交于 2020-01-06 08:48:13

问题


I am trying to convert named parameters to GET parameters for pagination at CakePHP 2.2 following the instructions given in the documentation but it is not working.

Instead of this:

http://localhost/cake/posts/yourPosts/page:2?url=posts%2FyourPosts

I want this:

http://localhost/cake/posts/yourPosts/?page=2&url=posts%2FyourPosts

The thing is, when i submit a form using GET method, i don't want to retain the current page, and currently, it is doing it by default because it is not a normal param but a named param.

(?url=posts%2FyourPosts is added automatically with the GET method)

I have tried to to this in my view but it stills passing the parameter as a named one:

$this->Paginator->options(array('convertKeys' => array('page')));

echo $this->Paginator->next(' >', array('class' => 'button next right'), null, array('class' => 'next button'));

What am I doing wrong?


回答1:


you should fix the issue at its source, not cloaking it: http://book.cakephp.org/2.0/en/core-libraries/components/pagination.html#pagination-with-get-parameters

public $paginate = array(
    'paramType' => 'querystring'
);

in your controller



来源:https://stackoverflow.com/questions/13007777/converting-named-parameters-to-get-parameters-for-pagination-at-cakephp-2-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!