本文介绍了如何传递参数在pagination在cakephp?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想传递参数在cakephp,我怎么办,当我搜索排序结果,然后点击2页的分页它不会记住url,我想传递我选择的形式dromdown的params,如何我通过分页中的参数在我的控制器代码是

I want to pass parameters in cakephp, how can I do that when I searched the sorted result and then click on 2 page of pagination it will not remember the url, I want to pass params which I selected form dromdown, how can I pass the params in pagination in my controller code is

        $membershipType = '';
    $status         = '';
    $timeSpan       = '';

    $fieldName = 'membership_Type';
    if(!empty($this->params->named["fieldName"])){
        $this->request->data['associations']["fieldName"] = $this->params->named["fieldName"];
    }
    $fieldName = 'statuses';
    if(!empty($this->params->named["fieldName"])){
        $this->request->data['associations']["fieldName"] = $this->params->named["fieldName"];
    }

    $fieldName = 'time_Span';
    if(!empty($this->params->named["fieldName"])){
        $this->request->data['associations']["fieldName"] = $this->params->named["fieldName"];
    }       

我想传递分页中的字段名称的值,这些?
在我看来代码是

I want to pass the value of fields name in pagination, how can I pass these?in my view the code is

 echo $this->PaginatorManager->options();

这两天我真的呆在这里,我不知道现在可以做什么?

I m really stucked here from two days, I dnt know wht can I do now? please help me, it will be appreciated many more, thanks a ton in advance.

推荐答案

您可以将url选项传递给pagination在你的视图中像这样:

You can pass 'url' option to pagination in your view like this:

$url = array_merge($this->request->pass, $this->request->named);
unset($url['page']);
$parts = explode('?', $_SERVER['REQUEST_URI'], 2);
if (count($parts) == 2) {
    $url['?'] = $parts[1];
}
$this->Paginator->options(array(
    'url' => $url,
));

更多此处:
,其中:

如果您广泛使用过滤器和其他网址参数,请创建一个可为您处理的元素

If you widely use filters and additional url params - make an element which will handle it for you

这篇关于如何传递参数在pagination在cakephp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 13:05