0

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

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

更新:我将代码更改为如下所示

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

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

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

4

2 回答 2

3

我最终使它工作在控制器的顶部添加

public $components = array('Paginator');

然后在我的方法中

$this->Paginator->settings['Tagged'] = array(
    'tagged',
    'model' => 'Upload',   
    'by' => $tagname
);
$this->Paginator->paginate('Tagged');
于 2014-11-04T17:34:43.513 回答
0

我经历了重载属性的间接修改 $paginate ...没有效果”错误

那是您的问题,而不是真正的错误。CakePHP 发生了一些变化,试试这个:

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

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

于 2014-03-05T22:01:37.167 回答