Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.2

Bug #2392 Nodes open expanded on mulitiple menus
Submitted: 2004-09-24 15:57 UTC
From: tanlis_dsl at yahoo dot com Assigned: richard
Status: Closed Package: HTML_TreeMenu
PHP Version: 4.3.6 OS: Mac OSX
Roadmaps: 1.2.1    
Subscription  
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes. If this is not your bug, you can add a comment by following this link. If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
2006-12-27 04:39 UTC
Package:
Bug Type:
Summary:
From: tanlis_dsl at yahoo dot com
New email:
PHP Version: Package Version: OS:

 

 [2004-09-24 15:57 UTC] tanlis_dsl at yahoo dot com
Description: ------------ Having more than one menu will cause the same node indice I open on the first menu to also be open on the second menu. ie, Menu 1 Cars - Ford - Toyota Motorcycles - Honda - Kawasaki If I open the Cars node and click Ford which takes me to another page with a menu it will show up as below. Menu 2 Ford - Mustang - GT - Cobra - Explorer - F150 The Mustang node is automatically opened by the resetBranches javascript function because the cookie is stored with node1 being open. Reproduce code: --------------- Page 1: $menu = new HTML_TreeMenu(); $node = new HTML_TreeNode(array("text" => "Cars", "link" => "test.php?type=cars")); $cnode = &$node->addItem(new HTML_TreeNode(array("text" => "Ford", "link" => "test.php?ctype=Ford"))); $cnode = &$node->addItem(new HTML_TreeNode(array("text" => "Toyota", "link" => "test.php?ctype=Toyota"))); $menu->addItem($node); $node = new HTML_TreeNode(array("text" => "MotorCycles", "link" => "test.php?type=motorcycles")); $cnode = &$node->addItem(new HTML_TreeNode(array("text" => "Honda", "link" => "test.php?ctype=Honda"))); $cnode = &$node->addItem(new HTML_TreeNode(array("text" => "Kawasaki", "link" => "test.php?ctype=Kawasaki"))); $menu->addItem($node); Page 2: $menu = new HTML_TreeMenu(); $node = new HTML_TreeNode(array("text" => "Mustang", "link" => "test.php?ctype=mustang")); $cnode = &$node->addItem(new HTML_TreeNode(array("text" => "GT", "link" => "test.php?ctype=GT"))); $cnode = &$node->addItem(new HTML_TreeNode(array("text" => "Cobra", "link" => "test.php?ctype=Cobra"))); $menu->addItem($node); $node = new HTML_TreeNode(array("text" => "Explorer", "link" => "test.php?type=explorer")); $menu->addItem($node); $node = new HTML_TreeNode(array("text" => "F150", "link" => "test.php?type=f150")); $menu->addItem($node); Expected result: ---------------- All menus should be separate and not expanded unless specificed in the php code If a node is opened on one menu, the corresponding node on a second menu should not be opened as well. Possible solution would be to provide an optional identifier on creation of the menu as currently objTreeMenu_1 is the default name of the first menu on a page.

Comments

 [2004-09-24 17:13 UTC] tanlis_dsl at yahoo dot com
Here is a patch that will allow a name to be passed in the constructor of the menu. This allows the states of each menu to be separate throughout a site. Index: TreeMenu.php ======================================================== =========== RCS file: /repository/pear/HTML_TreeMenu/TreeMenu.php,v retrieving revision 1.18 diff -u -r1.18 TreeMenu.php --- TreeMenu.php 20 Dec 2003 13:10:59 -0000 1.18 +++ TreeMenu.php 24 Sep 2004 17:09:11 -0000 @@ -70,13 +70,20 @@ var $items; /** + * Name of menu + * @var string + */ + var $menuName; + + /** * Constructor + * Sets the name of the menu to objTreeMenu_ by default if one is not supplied. * * @access public */ - function HTML_TreeMenu() + function HTML_TreeMenu($mname = "objTreeMenu_") { - // Not much to do here :( + $this->menuName = $mname; } /** @@ -616,7 +623,7 @@ function toHTML() { static $count = 0; - $menuObj = 'objTreeMenu_' . ++$count; + $menuObj = $this->menu->menuName . ++$count; $html = "\n"; $html .= '<script language="javascript" type="text/javascript">' . "\n\t";
 [2005-03-02 02:17 UTC] richard
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.