如何使用cakeDC searchplugin解决cakePHP中的分页错误

时间:2013-02-28 20:11:38

标签: cakephp search plugins cakephp-2.3 cakedc

我正在使用CakeDC(https://github.com/CakeDC/search)的searchplugin和cakePHP 2.3.0。该插件工作正常。我在这样的索引操作中有一点错误。谢谢你。

Indirect modification of overloaded property AtlasController::$paginate has no effect [APP\Controller\AtlasController.php, line 47]

我的索引动作

public function index() {
    $this->Prg->commonProcess();
    $this->paginate['conditions'] = $this->Atla->parseCriteria($this->passedArgs);
    $this->Atla->recursive = 0;
    $this->set('atlas', $this->paginate());
    $this->set('_serialize',array('atlas'));
}

问题是,我该如何解决?所以我发现了一种简单易行的方式。

2 个答案:

答案 0 :(得分:0)

所以这是解决方案,它在我的实现上运行。

我更改了paginate() - 来自。

的调用
$this->set('atlas', $this->paginate());

到新的paginate() - 调用。

this->set('atlas', $this->paginate($this->Atla->parseCriteria($this->passedArgs)));

这里是新的索引动作。

public function index() {
    $this->Prg->commonProcess();
    $this->Atla->recursive = 0;
    $this->set('atlas', $this->paginate($this->Atla->parseCriteria($this->passedArgs)));
    $this->set('_serialize',array('atlas'));
}

答案 1 :(得分:0)

我认为代码没有开箱即用的原因是['options']密钥。从$this->paginate['options']中删除密钥,并将模型作为参数添加到$this->set()中,并且分页应按预期工作。请参阅下面的修改代码示例。

public function index() {
    $this->Prg->commonProcess();
    $this->paginate = $this->Atla->parseCriteria($this->passedArgs);
    $this->Atla->recursive = 0;
    $this->set('atlas', $this->paginate('Atla'));
    $this->set('_serialize',array('atlas'));
}