0

我正在使用来自 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'));
}

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

4

2 回答 2

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'));
}
于 2013-02-28T20:11:38.040 回答
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'));
}
于 2013-10-28T08:41:46.967 回答