2013-02-28 19 views
0

我使用cakeDCP(https://github.com/CakeDC/search)與cakePHP 2.3.0的searchplugin。該插件工作正常。我在這樣的索引操作中遇到了一點問題。感謝那。如何解決分頁 - cakePHP與cakeDC錯誤searchplugin

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')); 
} 

的問題是,我該如何解決呢?所以我發現了一種如此簡單和容易的方式。

回答

0

所以這是解決方案,運行在我的實施。

我改變了paginate() - 來自。

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

to the new paginate() - call。

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')); 
} 
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')); 
}