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:09

embedding sub menus


Poster: autumnnn
Dated: Thursday September 25 2003 - 10:14:05 BST

Hi,

I'm dynamically generating the menus from a database and I need to put the sub menu inside the top level menu like so:

Code:

with(milonic=new menuname("Home")){
style=menuStyle;
aI("text=Item 1;url=http://www.milonic.com/cbuy.php;");
aI("text=Item 2 with submenu;showmenu=Sub;");

   with(milonic=new menuname("Sub")){
   style=menuStyle;
   aI("text=Sub1;url=http://www.spamcop.net/;");
   aI("text=Sub2;url=http://www.spamcop.net/;");
   }
}

aI("text=Item 3;url=http://www.milonic.com/forum/;");
}



this works fine and Item 2 shows the submenu items ok. but it just adds Item 3 to the sub menu not the top level menu.

I hope that makes sense. Any suggestions?

thanks
A


Poster: Hergio
Dated: Thursday September 25 2003 - 13:13:54 BST

Some people have tried and done this before. I think the reason its doing that is each aI call reference the CURRENTLY building menu, so if you start a new menu with the with(milonic=... then any subsequent aI will be added to the newest one.

You should probably change the way you dynamically generate your menus. Rather than do it depth-first like you are trying to do, create it breadth-first. Basically what I mean is, you'll have to create the menu code in layers, not hierarchial. I know this maynot be how you have things stored in your database or whatever dynamic source, but its how it needs to be done at the moment.

Hey Andy, this brings up an interesting point. What if one wanted to add items after the fact? Can it be done currently, or easily with a few changes? Like can one say with( getMenuByName("main1') ){ ...add more aI items... } or something to that effect (cuz I tried this and it dont work).

I was thinking maybe making the aI accept another parameter called menu where you could specify what menu that particular aI would be adding to. Like for default, you could say menu=this or not put it in and it would assume the currently building menu. But if you put in, say, menu=main1 then it would add itself to main1's list of items. What do you think?


Poster: Andy
Dated: Thursday September 25 2003 - 14:30:18 BST

This has already been done.

There is a new function called insertItem that can be used to insert a new menu item from anywhere within the menu data file. The idea is that users who need menus built based on information from different places can do so. It's also another way of building menus.

What you do is declare a menu as normal and then, for example, at the bottom of the data file insert a menu item into a menu that was previously built.

I'm really going to have to get a demo of this as it's more complicated to exaplain than it is to show you.

I'm working on demos now so should have something soon.

Cheers
Andy


Poster: autumnnn
Dated: Thursday September 25 2003 - 23:44:36 BST

fantastic!

that should solve my problem. would you mind just posting a little message here saying where the demo is? (when it's done)

I would really appreciate it.

thanks
A