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:37
Tree menu > start in expanded state
Poster: ScottN
Dated: Wednesday July 20 2005 - 18:38:54 BST
I've seen a couple of threads for the open by URL script, (which doesn't appear to be on the server anymore) but I'm not sure how it would work for me. I'm looking to have several submenus in a tree expanded when the page loads.
I'd like to be able to flag each submenu as "open" if I want it to open on page load. Fully expanding the tree would probably work too, but the ideal situation would be a simple flag that lets me specify what will start as open. Is there functionality already built to do any of this, or should I get to writing it myself?
Poster: Ruth
Dated: Wednesday July 20 2005 - 21:39:22 BST
Hi Scott,
1. The way to 'manually' put in a code for the menu to be open is to use the built-in alwaysvisible=1; but the specified menu would be always visible on all pages that have the menu.
2. If you are asking is there some built in way in the menu_data.js file to have it open on specific pages, no there isn't as far as I know
3. The module you want is the openmenusbyurl.js. That is the 'built-in' / bolt-on way to have each submenu open on its related pages. As far as I know you can't 'specify a page' on which to have it open, the module is kind of like a 'pagematch' capability, which when the page matches to the submenus it opens the submenu. I'm not sure, but I guess you could put that module on the pages where you want the submenu that matches to be open and leave it off other pages that it matches but you don't want it to be open. But, I think you'd have to play with it to see how or if it would work that way.
The module is still available. It's under the Milonic Bolt-on Modules It is right below the treemenu module.
There is also available a demo of a function called changeMenuProperty(). You might be able to use that to specify that a submenu is opened on particular pages. You'll have to read the information on the page on how to use it. At the bottom of the page is a link for 'Other Demos' which shows the one for changing alwaysvisible to off, but I would guess you could just reverse it and change it to on. I think you might have to have alwaysvisible=0; specified in the particular submenus to do that.
Hope this helps.
Ruth
Poster: ScottN
Dated: Thursday July 21 2005 - 15:23:25 BST
Hey Ruth,
Thanks for the response. The openmenubyurl script isn't quite what I'm looking for. I want the menu to start partially expanded, but to the same level on every page. That would be ideal for my application.
I've been looking at adding functionality like this to the treemenu.js script, but it's very difficult because the code uses mysterious variable names to save filesize. Maybe If Andy thinks it's a worthwhile feature (being able to add flags that make a submenu expanded by default) he will add it. It should be simple to add, but I'm having the hardest time getting the existing code.
Poster: Ruth
Dated: Thursday July 21 2005 - 16:49:19 BST
Hi Scott,
There is a separate function that was written before openmenusbyurl was available. It was written for a specific request. The topic is here [it begins where Kevin is actually writing the function because the topic includes a lot of other stuff not related]
The demo is up but it is not linked since the openmenusbyurl.js module was created. You can see the auto_open_subs_demo here with the explanation.
This does use onLoad statements, so I thought maybe, since you seem to know functions you can fiddle it to be what you want. I do suggest you read the topic post to get a handle on what Kevin did, he explains it pretty thoroughly, and as problem arose for the person requesting the function, those were also addressed. There are 3 functions involved.
This wasn't written for the treemenu [not sure if that was available at the time] so again, I don't know if it would work with that, or if you can use it to create a function you could use for what you want.
Ruth
Poster: ScottN
Dated: Thursday July 21 2005 - 19:26:15 BST
Thanks Ruth. I'll play with this and see if i can get the desired effect. If I do, I'll make sure to post my solution for others in the future.
Poster: ScottN
Dated: Wednesday July 27 2005 - 13:32:25 BST
Just posting to let you know I'm too inept to get the code working properly. I'll keep working at it, but if you have any other suggestions I would appreciate them.
Poster: Ruth
Dated: Wednesday July 27 2005 - 15:56:33 BST
Hi Scott,
No other suggestions, however, if you could post a test page with the menu on it so we can see what you're trying to do we could also work on it.
We'd need some direction as to which menus you want to have be open when you arrive at a page.
Ruth
Poster: ScottN
Dated: Wednesday July 27 2005 - 16:28:30 BST
Hey Ruth,
I'll try to put together a test page later on today. Im working for a company that works closely with the government, and because of a proprietary information agreement, I can't post the actual files. There's nothing overly sensitive about the menu, but I want to stay on the safe side. I'll put together a test page that's similar to my current menu.
Basically what I wantis to have the first (main) level and the second level expanded when the page loads. I want the third level closed by default. I'll try to draw the hierarchy with lists below. If it doesn't work, I make it in an html page.
- FIRST LEVEL
- Second Level
Second Level
Second Level
- third level*
third level*
third level*
- Second Level
Second Level
Second Level
Second Level
*these options should be hidden when the page loads
If that doesn't make sense, let me know and I'll try to better illustrate.
Poster: Ruth
Dated: Wednesday July 27 2005 - 22:08:01 BST
Hi Scott,
It makes sense. It sounds as if you want certain things open on certain pages, so I really need to see at least 2 pages, 3 would be preferible having 1 with nothing open, a link in the menu to page 2 where one sub is to be open and another link in the menu to page 3 where a different one is open, and the tree data file.
I'll try to make up a tree_menu data file, and some pages, but it may take me some time, so if you had something I'd just go get and download those pages and the files to play.
Ruth
Poster: Sairento
Dated: Thursday July 28 2005 - 2:03:23 BST
Been trying something similar, the code below uses the treemenu mod to have all options in a submenu open if one of it's fellow options has been selected previously.
Code:
function keepOpen(menuName) {
// Keep collapsible menu open
// Currently does this by re-opening the same menu that was closed
/*Don't need this block
var menuNum = getMenuByName(menuName);
_m[menuNum].treemenu=1;
menuDisplay(menuNum,"Show");
*/
_oTree();
}
locationURL = delineate(document.location.href);
with(milonic=new menuname("Main Menu")){
closeonclick=false;
style=menuStyle;
alwaysvisible=1;
left=0;
orientation="vertical";
top=180;
aI("image=images/home_closed.gif;url=default.asp;status=Home");
tmp="showmenu=CorporateProfile;image=images/corporate_closed.gif;";
switch(locationURL) {
case 'about_futuris.asp': case 'history.asp': case 'divisions.asp':
case 'directors.asp': case 'executive_management.asp': case 'corporate_contacts.asp':
tmp+="type=tree;image=images/corporate_open.gif;url=javascript:top.keepOpen('CorporateProfile');";
break;
} aI(tmp);
}
drawMenus();
// Keep collapsible menu open
// Currently does this by re-opening the same menu that was closed
/*Don't need this block
var menuNum = getMenuByName(menuName);
_m[menuNum].treemenu=1;
menuDisplay(menuNum,"Show");
*/
_oTree();
}
locationURL = delineate(document.location.href);
with(milonic=new menuname("Main Menu")){
closeonclick=false;
style=menuStyle;
alwaysvisible=1;
left=0;
orientation="vertical";
top=180;
aI("image=images/home_closed.gif;url=default.asp;status=Home");
tmp="showmenu=CorporateProfile;image=images/corporate_closed.gif;";
switch(locationURL) {
case 'about_futuris.asp': case 'history.asp': case 'divisions.asp':
case 'directors.asp': case 'executive_management.asp': case 'corporate_contacts.asp':
tmp+="type=tree;image=images/corporate_open.gif;url=javascript:top.keepOpen('CorporateProfile');";
break;
} aI(tmp);
}
drawMenus();