function getChildren(&$i) { global $sections; //echo "i=".$i."<br>"; if ($sections[$i]->depth == $sections[$i + 1]->depth) { return array(); } else { $ret_depth = $sections[$i]->depth; $i++; $ret_array = array(); for ($i; $i < count($sections); $i++) { // start setting up the objects to return $obj = null; $obj->text = $sections[$i]->name; if ($sections[$i]->active == 1) { $obj->url = $sections[$i]->link; } else { $obj->url = "#"; $obj->onclick = "onclick: { fn: return false }"; } //echo "i=".$i."<br>"; if (navigationmodule::hasChildren($i)) { $obj->submenu = null; $obj->submenu->id = $sections[$i]->name . $sections[$i]->id; //echo "getting children of ".$sections[$i]->name; $obj->submenu->itemdata = $this->getChildren($i); $ret_array[] = $obj; } else { $ret_array[] = $obj; } if ($i + 1 >= count($sections) || $sections[$i + 1]->depth <= $ret_depth) { return $ret_array; } } } }