Cakephp 与元素一起使用时出现分页错误

Cakephp 与元素一起使用时出现分页错误,cakephp,element,paginator,Cakephp,Element,Paginator,我有一个表中的视图,当我将它用作视图时,它可以很好地使用分页(Paginator->sort())。但当我将is更改为元素时,它将抛出错误: Warning (2): array_merge() [function.array-merge]: Argument #1 is not an array [CORE\cake\libs\view\helpers\paginator.php, line 194]<br> Warning (2): array_merge() [function

我有一个表中的视图,当我将它用作视图时,它可以很好地使用分页(Paginator->sort())。但当我将is更改为元素时,它将抛出错误:

Warning (2): array_merge() [function.array-merge]: Argument #1 is not an array [CORE\cake\libs\view\helpers\paginator.php, line 194]<br>
Warning (2): array_merge() [function.array-merge]: Argument #2 is not an array [CORE\cake\libs\view\helpers\paginator.php, line 194]<br>
Warning (2): array_merge() [function.array-merge]: Argument #1 is not an array [CORE\cake\libs\view\helpers\paginator.php, line 378]<br>
Warning (2): array_merge() [function.array-merge]: Argument #2 is not an array [CORE\cake\libs\view\helpers\paginator.php, line 378]<br>
控制器:更改paginate子句以将值返回到元素

return $collaborations = $this->paginate('Collaboration');
元素:在元素的开头添加了请求操作,另一行是如何调用分区排序

<?php $collaborations = $this->requestAction('/collaborations/calendar'); ?>
<?php echo $this->Paginator->sort('Pvm','Collaboration.start_date'); ?>

为什么我的分页排序功能不能工作?我还有别的东西要申报吗?我在谷歌上搜索了一下,发现paginator在查看/查找数据模型(在某处声明)方面可能有问题,或者它需要一些参数来分配给它

提前感谢:)

查看cakephp书籍:

您必须在控制器中设置paginate变量,然后使用paginate方法填充视图中的数据

应在控制器中而不是模型中配置辅助程序

例如,您的控制器类应该如下所示:

class ColaborationController extends AppController {
    var $paginate = array( 'limit'=>25, 'order'=>array('Colaboration.start_date'=>'asc'));

    function some_action() {
        $this->set('collaborations', $this->paginate('Collaboration'));
    }
}
你的看法是:

<?php echo $this->Paginator->sort('Pvm','collaboration.start_date'); ?>


我对解决这个问题感到厌烦。我改变了整个应用程序的逻辑,现在它运行良好。元素中的分页没有问题(根本没有分页元素),我也不必使用requestAction方法——我了解到这对性能不好,应该避免。谢谢大家的帮助:)

实际上,上面的示例在使用with view时效果很好。按照您描述的方式,将同时给出“无效参数”(数据集不工作)和数组合并错误。您必须记住,这个视图是作为一个元素运行的,数据必须像这样返回到元素:return$collaborations=$this->paginate('Collaboration');将控制器行更改为:return$collaborations=$this->paginate('Collaboration');正在提取数据集。但是分页排序仍然存在问题。我更改了其他所有内容,但运气不好。我正在使用cakephp 1.3,它的工作原理与我写的一样(我也有带分页的元素),我不知道,也许在下一个版本中它不起作用。请在调用元素时尝试以下操作:$this->element($col_element',$colaborations)一些注释和观察结果。我使用的是CakePHP1.3。尚未启用或配置可包含的行为。
<?php echo $this->Paginator->sort('Pvm','collaboration.start_date'); ?>