Variable depth dynamic menu

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
jsmith
Beginner
Beginner
Posts: 1
Joined: Thu Oct 21, 2004 12:08 pm
Location: Americas

Variable depth dynamic menu

Post by jsmith »

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: Select all

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: Select all

with(milonic=new menuname("Main Menu")){
style=menuStyle;
top=220;
left=180;
alwaysvisible=1;
orientation="horizontal";
aI("text=Home;url=http://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: Select all

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?
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

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://milonic.com/forum/viewtopic.php?p=22896

Ruth
Post Reply