问题
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