2014-03-05 77 views
0

我有問題讓CakeDC的標籤插件工作。我已經非常仔細地閱讀了文檔,但看起來文檔非常陳舊。CakePHP標籤插件分頁問題

// Totally works. Does what it is supposed to do, does not 
// complain of missing models. 
     $tag = $this->Upload->Tagged->find('tagged', 
     array('by' => $tagname, 'model' => 'Upload', 'conditions' => 
     array('Upload.soft_delete !=' => 1))); 


// 100% correct according to the 3 year old documentation. 
// Complains of a missing "taggeds" model. 
// Table taggeds for model Tagged was not found in datasource default. 
// Undefined index: tagged [CORE/Cake/Model/Model.php, line 2731] 


     $this->paginate['Tagged'] = array(
         'model' => 'Upload', 
         'tagged', 
         'by' => $tagname); 

     $tag = $this->paginate('Tagged'); 

我在這裏閱讀文檔:https://github.com/CakeDC/tags/wiki/Find-tagged-objects

起初,我經歷重載屬性$ PAGINATE ......沒有效果」的錯誤的間接修改,直到我說公衆$ PAGINATE =陣列(); 。到了我的控制器的頂部。這並沒有幫助其他錯誤

希望我失去了一些東西簡單在這裏

UPDATE:我改變了代碼看起來像這樣

$this->Paginator->settings['Tagged'] = array(
     'tagged', 
     'model' => 'Upload',  
     'by' => $tagname 
    ); 

$this->Paginator->paginate('Tagged'); 

,我得到這個錯誤:錯誤:調用一個成員函數PAGINATE()非對象

回答

0

I experienced the Indirect modification of overloaded property $paginate ... no effect" bug

那是你的問題,不是一個真正的錯誤上。 CakePHP已經改變了一點,試試這個:

$this->Paginator->settings['Tagged'] = array(
    'tagged', 
    'model' => 'Upload', 
    'by' => $tagname 
); 
$this->Paginator->paginate('Tagged'); 

歡迎您改進文檔。我們目前保持免費的14個插件,任何形式的幫助表示讚賞。回饋並幫助改進文檔。 :)

+0

「錯誤:調用一個成員函數PAGINATE()一個非對象「以及」間接修改重載屬性SearchesController :: $ Paginator不起作用「 – baordog

3

我最終取得了控制器的前頭工作增加

public $components = array('Paginator'); 

然後在我的方法

$this->Paginator->settings['Tagged'] = array(
    'tagged', 
    'model' => 'Upload', 
    'by' => $tagname 
); 
$this->Paginator->paginate('Tagged');