From 2ae046557fea9b859c81dec84494a3c8dffb5522 Mon Sep 17 00:00:00 2001 From: hagen00 Date: Tue, 18 Jul 2017 13:38:47 +0200 Subject: [PATCH 1/2] Update tree.rst Update docs, indicating how to pass conditions to the finder --- en/orm/behaviors/tree.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/en/orm/behaviors/tree.rst b/en/orm/behaviors/tree.rst index e9e5d2ae9d..c22afee586 100644 --- a/en/orm/behaviors/tree.rst +++ b/en/orm/behaviors/tree.rst @@ -69,6 +69,17 @@ Getting a flat list of the descendants for a node is equally easy:: foreach ($descendants as $category) { echo $category->name . "\n"; } + +If you need to pass conditions you would do it as follows: + + $descendants = $categories + ->find() + ->where(['name LIKE' => '%Foo%']) + ->find('children', ['for' => 1]); + + foreach ($descendants as $category) { + echo $category->name . "\n"; + } If you instead need a threaded list, where children for each node are nested in a hierarchy, you can stack the 'threaded' finder:: From 325b2cc019aa14cc5a6f7792c44522300c78022f Mon Sep 17 00:00:00 2001 From: hagen00 Date: Tue, 18 Jul 2017 14:12:40 +0200 Subject: [PATCH 2/2] Update tree.rst adding missing (second) colon. --- en/orm/behaviors/tree.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/orm/behaviors/tree.rst b/en/orm/behaviors/tree.rst index c22afee586..1f94baa5d0 100644 --- a/en/orm/behaviors/tree.rst +++ b/en/orm/behaviors/tree.rst @@ -70,7 +70,7 @@ Getting a flat list of the descendants for a node is equally easy:: echo $category->name . "\n"; } -If you need to pass conditions you would do it as follows: +If you need to pass conditions you would do it as follows:: $descendants = $categories ->find()