2014-03-05 37 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');