表格中有CakePHP 1.3
多个树,moveup
和movedown
我设置了
$this->Category->Behaviors->attach('Tree', array(
'scope' => array(
'Category.parent_id' => $node['Category']['parent_id'],
),
));
但记录也按type
分类,所以我也需要
'Category.type' => $node['Category']['type'],
并且像这样没有任何区别。
以下是我的数据示例:
id | parent_id | lft | rght | Title | type
1 | null | 1 | 4 | Cat1 | categoory
2 | null | 5 | 20 | Cat2 | categoory
3 | 2 | 6 | 13 |Cat2.1 | categoory
4 | 2 | 14 | 15 |Cat2.2 | categoory
5 | 2 | 16 | 17 | img1 | image
6 | 1 | 2 | 3 | img1 | image
7 | 2 | 18 | 19 | img2 | image
8 | 3 | 7 | 8 | Post1 | post
9 | 3 | 9 | 10 | Post2 | post
10 | 3 | 11 | 12 |Cat2.1.1| categoory
答案 0 :(得分:1)
您应该确定'type'字段而不是'parent_id'字段。需要每次都根据您要使用的子树设置范围。
$this->{$this->nodeType}->Behaviors->attach('Tree', array(
'scope' => array(
'Category.type' => $this->nodeType,
),
));