Re: [PHP] Working with Multi by Multi levels menu
> Marek wrote: > > Hiya Marek K, > > > > Thanks for the link, however on that page the links regarding a "Modified > > Preorder Tree Traversal Algorithm" come up as 404. > > Then see: > http://www.sitepoint.com/article/hierarchical-data-database/2 This article is specifically for a database driven hierarchical data. Mine has to be memory based(as little as possible), a sort of flat based but yet efficient and elegant. I think I have a solution.. working on it now Thanks > > I would prefer not to use > > recursion until the third stage (display of menu). In fact I know, I will > > not use recursion for the first or second, simply because for each > > addition/change a recursion seems and is an overkill. The idea here is to > > have very elegant and simple code that can also be used in other > > classes/projects. I'm pretty much going to stick to what I have already > > where the only recursion that occurs is in the third stage (display of > > menu). > > > > One thing I forgot to add to in my original email is that the $element > > property also has an order id(int) for displaying the menus in particular > > order. > > > > My first and the second stage allow me to change/add elements directly > > without searching for them. Whereas the display does a recursion that > > displays in order. All of this done within php, so first and the second > > stage in reality is like an indexed stack. The third stage might get a > > little tricky due to the order property... if you have any ideas/tricks, > > please let me know. > > I think flat table model is suited for you just right. Updating it is a > little ugly but it's not that big deal. > > You can also think about caching the result. > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Working with Multi by Multi levels menu
Marek wrote: Hiya Marek K, Thanks for the link, however on that page the links regarding a "Modified Preorder Tree Traversal Algorithm" come up as 404. Then see: http://www.sitepoint.com/article/hierarchical-data-database/2 I would prefer not to use recursion until the third stage (display of menu). In fact I know, I will not use recursion for the first or second, simply because for each addition/change a recursion seems and is an overkill. The idea here is to have very elegant and simple code that can also be used in other classes/projects. I'm pretty much going to stick to what I have already where the only recursion that occurs is in the third stage (display of menu). One thing I forgot to add to in my original email is that the $element property also has an order id(int) for displaying the menus in particular order. My first and the second stage allow me to change/add elements directly without searching for them. Whereas the display does a recursion that displays in order. All of this done within php, so first and the second stage in reality is like an indexed stack. The third stage might get a little tricky due to the order property... if you have any ideas/tricks, please let me know. I think flat table model is suited for you just right. Updating it is a little ugly but it's not that big deal. You can also think about caching the result. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Working with Multi by Multi levels menu
Hiya Marek K, Thanks for the link, however on that page the links regarding a "Modified Preorder Tree Traversal Algorithm" come up as 404. I would prefer not to use recursion until the third stage (display of menu). In fact I know, I will not use recursion for the first or second, simply because for each addition/change a recursion seems and is an overkill. The idea here is to have very elegant and simple code that can also be used in other classes/projects. I'm pretty much going to stick to what I have already where the only recursion that occurs is in the third stage (display of menu). One thing I forgot to add to in my original email is that the $element property also has an order id(int) for displaying the menus in particular order. My first and the second stage allow me to change/add elements directly without searching for them. Whereas the display does a recursion that displays in order. All of this done within php, so first and the second stage in reality is like an indexed stack. The third stage might get a little tricky due to the order property... if you have any ideas/tricks, please let me know. Thanks Marek J - Original Message - From: "Marek Kilimajer" <[EMAIL PROTECTED]> To: "Marek" <[EMAIL PROTECTED]> Cc: Sent: Wednesday, January 26, 2005 5:49 AM Subject: Re: [PHP] Working with Multi by Multi levels menu > Marek wrote: > > Hello > > > > Creating a three dimensional menu system is pretty easy with arrays, but > > when you want to create a menu system that is 10 or 15 levels deep using > > arrays the conventional method is not so simple. > > > > I'm writing an application that shows a multi level (up to 30 levels) menu > > which is generated dynamically not in any particular order. There are three > > stages: > > > > First stage, generates the levels of the menu and assigns titles, > > Second stage needs to come the levels and change its properties, ie icon, > > font, colour, etc. This is a critical part of the process as the menus are > > not generated in any order and this stage also changes the properties of the > > level not in any particular order. > > The third stage needs to display this menu. > > > > My search on hotscripts and google didn't turn up anything that's relevant. > > I know I can write a recursive function for each of these stages, but thats > > not the best method. > > One recursive function that will take care of all stages. > > I'm not sure what table design you desided use, at level this deep you > might use Flat Table or Modified Preorder Tree Traversal Algorithm: > http://www.evolt.org/article/Four_ways_to_work_with_hierarchical_data/17/404 7/ > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Working with Multi by Multi levels menu
Marek wrote: Hello Creating a three dimensional menu system is pretty easy with arrays, but when you want to create a menu system that is 10 or 15 levels deep using arrays the conventional method is not so simple. I'm writing an application that shows a multi level (up to 30 levels) menu which is generated dynamically not in any particular order. There are three stages: First stage, generates the levels of the menu and assigns titles, Second stage needs to come the levels and change its properties, ie icon, font, colour, etc. This is a critical part of the process as the menus are not generated in any order and this stage also changes the properties of the level not in any particular order. The third stage needs to display this menu. My search on hotscripts and google didn't turn up anything that's relevant. I know I can write a recursive function for each of these stages, but thats not the best method. One recursive function that will take care of all stages. I'm not sure what table design you desided use, at level this deep you might use Flat Table or Modified Preorder Tree Traversal Algorithm: http://www.evolt.org/article/Four_ways_to_work_with_hierarchical_data/17/4047/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Working with Multi by Multi levels menu
Hello Creating a three dimensional menu system is pretty easy with arrays, but when you want to create a menu system that is 10 or 15 levels deep using arrays the conventional method is not so simple. I'm writing an application that shows a multi level (up to 30 levels) menu which is generated dynamically not in any particular order. There are three stages: First stage, generates the levels of the menu and assigns titles, Second stage needs to come the levels and change its properties, ie icon, font, colour, etc. This is a critical part of the process as the menus are not generated in any order and this stage also changes the properties of the level not in any particular order. The third stage needs to display this menu. My search on hotscripts and google didn't turn up anything that's relevant. I know I can write a recursive function for each of these stages, but thats not the best method. This is what I have so far: for the purpose of this email all menu items are called elements and their property is an array: element["parent"] = some other menu element (always an integer) assuming that 0 is the root element["title"] = title element["color"] = etc,etc. For the first stage: The first stage assigns the level and the title. A function like add_element( parentof, $element), function delete_element(parentof, $element) function move_elelement(newparentof, oldparentof, $element) to maintain the tracking and consistency each element will be added to the $v_menu varible as follows: $c is incremented for each function add_element where a new level exists $c_child is just a counter of the current element $v_menu[ $c ]["number of children"] = int $v_menu[ $c ]["parentof"] = parent of this child, 0 is root. $v_menu[ $c ][ $c_child ] = $element second stage function change_title(parentof, $element) this is where I am conteplating third stage just a recursive function to show it all in order for proper html display. ? the goal is something like this: | |---Menu 1 ||---Child of 1 | |Child of (1, 1) | | |---Child of(1,1,1) | |Child of (1,1) ||Child of (1,1,2) ||Child of (1,1,2) | |--Child of (1,1,2,2) Perhaps my approach is wrong on this ? Is there a cleaner method ? Thanks Marek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php