/** * Build an array tree from a given navigation item. * * Works by taking a node and attaches the children */ private function get_tree_down($navitem) { $children = new Model_Nav(); $children->where('parent = ?', $navitem->get('itemid')); $childs = array(); foreach ($children->getAll() as $child) { $childs[] = $this->get_tree_down($child); } if (!empty($childs)) { $navitem['children'] = $childs; } return $navitem; }