Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:06

Variable depth dynamic menu


Poster: jsmith
Dated: Thursday October 21 2004 - 13:57:55 BST

I have a database table that stores menu items in a parent child relationship. Here's the schema:

menu_id int(11)
menu_name varchar(50)
parent_id int(11)

Here is some possible data

Code:
Menu id     Name                Parent id
1              Yahoo                0
2              Yahoo Sports      1



So anything with a parent_id of 0, would be at the main menu level and here, Yahoo Sports would be a submenu of the Yahoo menu.

What if I didn't know the depth of the menus? Meaning, what if someone were to add a sub menu of Baseball to the Yahoo Sports menu item? Is there a way I can write the menu code to dynamically generate the menu based on the parent id's?

In your examples online, you provide this syntax:

Code:
with(milonic=new menuname("Main Menu")){
style=menuStyle;
top=220;
left=180;
alwaysvisible=1;
orientation="horizontal";
aI("text=Home;url=http://www.milonic.com/;status=Back To Home Page;");
aI("text=Menu Samples;showmenu=Samples;");
aI("text=Milonic;showmenu=Milonic;");
aI("text=Partners;showmenu=Partners;");
aI("text=Links;showmenu=Links;");
aI("text=My Milonic;showmenu=MyMilonic;");
}


But then to make a new sub menu, I need to do this:

Code:
with(milonic=new menuname("Samples")){
style=menuStyle;
overflow="scroll";
......etc.


If I didn't know how many submenus I might have, how would I create the code?
Code:
Code:


Poster: Ruth
Dated: Friday October 22 2004 - 7:36:39 BST

I'm sure this would take a function which I am unable to do. I realize you are speaking about a whole menu, however there is a post about adding a menu item dynamically after the menu is rendered so I thought they might give you some ideas. http://www.milonic.com/forum/viewtopic.php?p=22896

Ruth