与元素一起使用时出现分页错误
当我将其用作视图时,我有一个表视图,该视图可以很好地处理分页(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>
代码与以前完全相同,但我当然更改了一些代码,如下所示:
模型:添加了下一条语句
var $helpers = array('Paginator');
控制器:更改了分页子句以将值返回到元素
return $collaborations = $this->paginate('Collaboration');
元素:将请求操作添加到元素的开头,另一行是我如何调用配对排序
<?php $collaborations = $this->requestAction('/collaborations/calendar'); ?>
<?php echo $this->Paginator->sort('Pvm','Collaboration.start_date'); ?>
为什么我的分页排序功能无法工作?我还声明了什么吗?我做了一些谷歌搜索,我发现分页器可能无法查看/查找数据模型(在某处声明),或者需要为其分配一些参数?
提前致谢 :)
I habve a view from table which is working fine with pagination (Paginator->sort()) when I am using it as a view. But when i changed is as a element, it will throw errors:
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>
The code is exacty same as before, but I changed of course some of the code as follows:
Model:Added next statement
var $helpers = array('Paginator');
Controller: changed the paginate clause to return values to element
return $collaborations = $this->paginate('Collaboration');
Element: added request action into start of the element and the other line is how I call the parination sort
<?php $collaborations = $this->requestAction('/collaborations/calendar'); ?>
<?php echo $this->Paginator->sort('Pvm','Collaboration.start_date'); ?>
Why can't my pagination sort functionality work? Do I have declare something else? I did some Googling and I figured out that paginator might have problem to see/find datamodel (to be declared somewhere) or it would need some parameters to be assigned into it?
Thanks in advance :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查cakephp书: http://book.cakephp.org/1.3/en/view /1231/Pagination
您必须在控制器中设置 paginate 变量,然后使用 paginate 方法来填充视图中的数据。
助手应该在控制器中配置,而不是在模型中配置。
例如,您的控制器类应如下所示:
而您的视图:
Check cakephp book: http://book.cakephp.org/1.3/en/view/1231/Pagination
You have to set up the paginate variable in your controller and then use the method paginate to populate the data in the view.
Helpers should be configured in the controller not in the model.
Example, your controller class should look like:
And your view:
我厌倦了试图解决这个问题。我改变了整个应用程序逻辑,现在它工作正常。元素中的分页没有问题(根本没有分页元素),而且我不必使用 requestAction 方法 - 我读到它对性能不利,应该避免。感谢大家的帮助:)
I got bored trying to resolve this problem. I changed the whole application logic around and now it works fine. No problems with paginations in elements (no pagination elements at all) and I don't have to use requestAction method - I read that it is not good for performance and should be avoided. Thanks all for your help :)