0

テーブルにCakePHP 1.3複数のツリーがあり、formoveupmovedowniを設定します

    $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
4

1 に答える 1

1

You should be scoping on the 'type' field not 'parent_id' field. Need to set the scope each time depending on which subtree you want to work with.

$this->{$this->nodeType}->Behaviors->attach('Tree', array(
    'scope' => array(
        'Category.type' => $this->nodeType,
    ),
));
于 2012-09-16T07:10:07.557 に答える