在CakePHP 2.2中将命名参数转换为GET参数以进行分页 [英] Converting named parameters to GET parameters for pagination at CakePHP 2.2
问题描述
我尝试将命名参数转换为GET参数,以便在CakePHP 2.2上按照文档,但它不工作。
而不是这样: / p>
http:// localhost / cake / posts / yourPosts / page:2?url = posts%2FyourPosts
我想要:
http:// localhost / cake / posts / yourPosts /?page = 2& url = posts%2FyourPosts
事情是,当我使用GET方法提交表单时,我不想保留当前页面,目前,它是默认做它,因为它不是一个正常的参数,但是一个命名的参数。
(?url = posts%2FyourPosts 是使用GET方法自动添加的)
在我看来,尝试这样,但它仍然传递参数作为命名的:
$ this-> Paginator- > options(array('convertKeys'=> array('page')));
echo $ this-> Paginator-> next('>',array('class'=>'button next right'),null,array('class'=& 'next button'));
我做错了什么?
你应该解决这个问题,而不是掩盖它:
http://book.cakephp.org/2.0/en/core-libraries/components/pagination.html#pagination-with-get-参数
public $ paginate = array(
'paramType'=>'querystring'
);
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?
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
这篇关于在CakePHP 2.2中将命名参数转换为GET参数以进行分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!