3

我想在 cakephp 中传递参数,当我搜索排序结果然后单击分页的 2 页时,我该怎么做?我的控制器代码中的分页参数是

        $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"];
    }       

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

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

我真的被困在这里两天了,我不知道我现在该怎么办?请帮助我,将不胜感激,在此先感谢一吨。

4

2 回答 2

3

您可以将“url”选项传递给视图中的分页,如下所示:

$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,
));

更多在这里:http ://api.cakephp.org/2.2/class-PaginatorHelper.html 在这里:http: //book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::选项

如果您广泛使用过滤器和其他 url 参数 - 制作一个将为您处理它的元素

于 2013-03-21T15:15:02.500 回答
1

这对我有用:

我在 app.Config.routes.php 中定义了参数:

Router::connect('/my_account/*', array('controller' => 'ads', 'action' => 'my_account'), array(
'pass' => array('status')
));

然后在视图文件中:

$this->Paginator->options(array(
'url' => $this->request->pass
));
于 2013-05-05T19:36:56.293 回答