CakePHP标签插件分页问题

时间:2014-03-05 19:43:58

标签: cakephp tags cakedc

我在使用CakeDC的标签插件时遇到问题。我已经仔细阅读了文档,但似乎文档已经很老了。

// 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的间接修改...没有影响“bug,直到我添加public $ paginate = array();到我控制器的顶部。这没有帮助另一个错误。

希望我在这里遗漏一些简单的东西。

更新:我将代码更改为

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

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

我收到此错误:错误:在非对象上调用成员函数paginate()

2 个答案:

答案 0 :(得分:3)

我最终将其添加到Controller的顶部

public $components = array('Paginator');

然后在我的方法

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

答案 1 :(得分:0)

  

我经历了对重载属性的间接修改   $ paginate ...没效果“bug

这是你的问题而不是真正的错误。 CakePHP已经改变了一点,试试这个:

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

欢迎您改进文档。我们目前正在维护免费的 14个插件,我们非常感谢您提供任何帮助。回馈一些东西并帮助改进文档。 :)

相关问题