HTML_Menu nodes properties mapping in templates

From: Date: Sat, 13 Sep 2003 00:27:03 +0000
Subject: HTML_Menu nodes properties mapping in templates
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-7779@lists.php.net to get a copy of this message
First, Alexey, thanks for your great work on this package. I've been used this class for a while, found it very powerful and useful, and didn't understood why It was forgotten by pear gurus ;-) I wish to know if you think it will be possible to add other dynamic elements to the templates (with no limits), not limiting them to the three elements {url} {title} {indent}. It would be great if each node can have as many replacement tags we want. For example, I use in my own implementations of HTML_Menu (ulf wendel version) : - {level} = the level of the node in the tree. Very useful for setting css styles : td.menuLevel0, td.menuLevel1 for submenu1 etc. - {numInLevel} = the position inside the level (num 1 in level 0, num 2 in level 0, etc.). Again very useful for setting css style on a section basis. You can see an example of this in the left menu on http://www.brises.org/ (all the look and feel of the menu is setted by css classes menuLevel0num1 etc) - {sectionNum} = scientific notation 1.2.5 ... - {id} = the category_id (my menus are set as trees from db) - {anyNodeProperty} = what we can imagine (a specific class for this node, a string to append, a title attribute, etc.) Each of these are property of nodes ( $menu[node][property]) and have to be set outside of HTML_Menu (I believe), since it has to be sent to setMenu as an array. But HTML_Menu could allow users to set a customizable array for mapping node-properties to tags replacement in _entry template. For example : In renderEntry method, we could use an array set in an another method ??? $this->_rowHtml .= strtr($this->_entryTemplates[$type], $this->nodeProperty); And we can imagine a method setNodeProperties function setNodeProperties($array){ foreach($array as $key=>$value){ $this->nodeProperty[$key] = $value; } } Does it makes sense, or is it pure dream ?? I hope I was clear... Regards, Didier

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