【问题标题】:how ->find('threaded') can work with cakephp 3.x->find('threaded') 如何与 cakephp 3.x 一起工作
【发布时间】:2016-05-08 15:34:33
【问题描述】:

我正在尝试对类别表使用树行为。我刚刚使用蛋糕烘焙创建了modelcontrollercategoryTablecategory.php。它正在工作,但我试图将所有孩子都放在他的父母之下,在阅读了 cakebake 书后,我知道->find('threaded') 可以做到这一点。但它给出了错误。

错误是:

传递的变量不是数组或对象,而是使用空数组

完整的查询是:

$parentCategory = $this->Category->ParentCategory->find('list', ['limit' => 200])->find('threaded');

它给出了错误,但如果我删除 ->find('threaded') 则没有错误,但它会以与保存相同的顺序显示数据。

目前工作如下;

Parent 1
child 1
child 2

Parent 2
child 1
child 2
child 3(from parent 1)

虽然我想显示如下

parent 1
child 1 
child 2
child 3

parent 2
child 1
child 2

【问题讨论】:

    标签: cakephp tree cakephp-3.0


    【解决方案1】:

    这个怎么样:

    $parentCategories = $this -> Categories -> ParentCategories -> find('treeList', ['limit' => 200]);
    

    cakephp3 中的所有模型都必须是正则表达式

    Category 应该是 Categories 并且 ParentCategory 应该是 ParentCategories

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-17
      • 1970-01-01
      • 1970-01-01
      • 2015-09-18
      相关资源
      最近更新 更多