我在让 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()