Re: HTML_Menu - Menu Array
| From: | Leonie | Date: | Tue, 08 Jun 2004 04:38:27 +0000 |
| Subject: | Re: HTML_Menu - Menu Array | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-12989@lists.php.net to get a copy of this message | ||
A solution!
First I should have told you about the get_type function - which tests for
children:
// function: test whether this id is a branch or leaf
// returns: boolean
function get_type($id) {
$copy_links = $this->all_links;
reset($copy_links);
for ($x=0; $x<sizeof($copy_links); $x++) {
if ($copy_links[$x]['parent'] == $id) {
//has children
return 1;
}
}
}// end get_type
I only had to make one small change to my get_menu_tree function to make it
work. It was here:
$children[$no]["sub"] = $this->get_menu_tree($copy_links[$x]["id"], $no,
$y);
changed to:
if ($this->get_type($copy_links[$x]["id"])) {
$children[$no]["sub"] =
$this->get_menu_tree($copy_links[$x]["id"], $no, $y=0);
}
And there it is. A multi-dimensional array for use with HTML_Menu.
Luvly juvly,
Leonie