symfony2 - Not able to get children of children using StofDoctrineExtension Tree -



symfony2 - Not able to get children of children using StofDoctrineExtension Tree -

i have database created dynamically trial purposes. created parent(home), set children , created children of children(sub children can say).

now want list of sub-children.

my code

$pages = $this->getdoctrine()->getrepository('bloggerblogbundle:page'); $nodes = $pages->getchildren(); $parent = $nodes[0]; //get parent node $rootnodes = $parent->getchildren(); // children of parent nodes foreach($rootnodes $node) { $nodes = $node->getchildren(); // children of children }

now returning $nodes view , in homecoming sub-children of 1 children node instead of sub-children of children.

what error making here? please help, !!!

you resetting nodes variable on each foreach.

to nodes create array , add together subsequent nodes onto end of that.

$pages = $this->getdoctrine()->getrepository('bloggerblogbundle:page'); $nodes = $pages->getchildren(); $parent = $nodes[0]; //get parent node $children = $parent->getchildren(); // children of parent nodes $subchildren = array(); foreach ($children $child) { $subchildren = array_merge($subchildren, $child->getchildren()->toarray()); }

symfony2 stofdoctrineextensions

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -