我想在cakephp中传递参数,当我搜索排序后的结果,然后点击2页的分页时,我怎么能这样做呢?它不会记住url,我想通过我选择的形式dromdown的params,怎么能我在控制器代码
中传递了参数 $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();
我真的在这里呆了两天,我知道我现在可以做什么?请帮助我,非常感谢,感谢提前一点。
答案 0 :(得分: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::options
如果您广泛使用过滤器和其他网址参数 - 制作一个可以为您处理的元素
答案 1 :(得分: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
));