Can I display 2 different DBNested Set/HTML_Menus on the same page?

From: Date: Thu, 20 Sep 2007 15:59:00 +0000
Subject: Can I display 2 different DBNested Set/HTML_Menus on the same page?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-27959@lists.php.net to get a copy of this message
I'm displaying 2 menus on the one page using DBNestedSet and HTML_Menu The first menu 'urhere' uses getAllNodes() but the second menu just uses getBranch() I can't put my finger on it, but once the getAllnodes urhere menu is displayed the data somehow carries over and populates the array of the getBranch tree menu with all nodes instead of just the sub branch. This is even though I go through the DBNested process again. It looks like I somehow need to reset the data once the first menu has been displayed. Does anyone have any suggestions on the solution?? I've done quite a bit of trial and error, but nothing seems to work. Thanks _______BEGIN CODE FOR URHERE getAllNodes_______________ // Fetch the entire tree into an array $data = $nestedSet->getAllNodes(true); // Create the links foreach ($data as $id => $node) { $data[$id]['url'] = $_SERVER['PHP_SELF'].'?nodeID=' . $node['id'] . '&nodename=' . $node['name']; } // Send HTML_Menu the structure, title and URL for the items in our tree $params = array( 'structure' => $data, 'titleField' => 'name', 'urlField' => 'url'); // Create the output driver object $output =& DB_NestedSet_Output::factory($params, 'Menu'); // Fetch the menu array $structure = $output->returnStructure(); // We'll create the new HTML_Menu object, using the urhere display driver $menu = & new HTML_Menu($structure, 'urhere'); // Create the current URL and send it to HTML_Menu $currentUrl = $_SERVER['PHP_SELF'].'?nodeID=' . $_GET['nodeID'] . '&nodename=' . $_GET['nodename']; $menu->forceCurrentUrl($currentUrl); // Show the menu echo $menu->show(); _______END CODE FOR URHERE_______________ _______BEGIN CODE FOR TREE getBranch_______________ $data = $nestedSet->getBranch(1, true); // Create the links foreach ($data as $id => $node) { $data[$id]['url'] = $_SERVER['PHP_SELF'].'?nodeID=' . $node['id'] . '&nodename=' . filename_from_db_to_url($node['name']); } // Send HTML_Menu the structure, title and URL for the items in our tree $params = array( 'structure' => $data, 'titleField' => 'name', 'urlField' => 'url'); // Create the output driver object $output =& DB_NestedSet_Output::factory($params, 'Menu'); // Fetch the menu array $structure = $output->returnStructure(); $structure = & new HTML_Menu($structure); $renderer =& new HTML_Menu_DirectTreeRenderer; // Create the current URL and send it to HTML_Menu $currentUrl = $_SERVER['PHP_SELF'].'?nodeID=' . $_GET['nodeID'] . '&nodename=' . filename_from_db_to_url($_GET['nodename']); $structure->forceCurrentUrl($currentUrl); $structure->render($renderer, 'tree'); // Output the menu echo '<div id="mainleftnav" class="leftbox">'.$renderer->toHtml()."</div>"; _______END CODE FOR TREE_______________

« previous php.pear.general (#27959) next »