Scroll To Top

Enter a query to search our site. Note that you can use "*" and "?" as wildcards. Enclosing more than one word in double quotes ("CSS Layout") will search for the exact phrase.

PVII Knowledge Base

1. Select a product ...
2. Select category ...
3. Search the Knowledge Base...

Question #166

Is there a way to have the TreeMenu Magic system open the menu with only a specified number of sublevels open?

The Answer

Prepared Sep. 2005 by Gerry Jacobsen, PVII

Note: This functionality is included and fully automated in the more recent Tree Menu Magic 2 system, simply select the number of levels to open in the "Open to Level" dropdown option in the TMM2 user interface.

You can use this special JavaScript function, P7_TMopenLV(), instead of the normal "P7_TMopen(): function on the <body> tag, onLoad event. This will allow you to specify the number of levels you wish to have open when the page loads.

Here's the function:

function P7_TMopenLV(v){ //v1.0 by Project Seven Development(PVII)
  var i,x,ha,s,tN,g,lv;

Here's how it works:

1. Copy and paste this new JavaScript function, P7_TMopenLV(), into your p7tmscript.js file. Save the file.

2. In the existing <body> tag, onLoad event:

Change this:

<body onLoad="P7_TMclass();P7_TMopen()">

to this:

<body onLoad="P7_TMclass();P7_TMopenLV(1)">

The number in the P7_TMopen(2) behavior specifies the number of levels to open. To open the menu with just the first submenu levels open specify 1, to open the menu with 2 sublevels open, specify 2.

Don't forget to preserve your code tweak by following the instructions in our infoBase#122 article.

That's It!

Back to the questions list