Dynamic Menu Generation

In addition to loading the menu via ezdata.js, EZmenu also allows you to dynamically generate the menu content on the fly. For example, you may wish to have a user log in to your website, retrieve his authorizations from a database and generate a navigation menu accordingly.

In place of ezdata.js, the menu is defined by a javascript variable menuStr. The format of this variable is the same as the format used by the MenuMaker Panel Entries. As such, it is easy to use server or client side scripts like ASP, PHP or Javascript to generate this variable dynamically on the webpage. Click here to see an example.

The source of the example look something like:

<BODY>

<script>
var menuStr;

/* Use ASP or PHP to generate the following italicised portion. */
/* The format is the same as the MenuMaker Panel Entries. */
/* Note the use of \n to denote a new line. */

menuStr = "Type:Bar,....\n"
menuStr += "Panel=MainBar\n"
menuStr += "Item 1^^SubMenu1\n"
menuStr += "Item 2^http://yahoo.com^SubMenu2\n"
menuStr += "Item 3^http://yahoo.com\n"
menuStr += "Panel=SubMenu1\n"
menuStr += "Item 4\n"
menuStr += "Item 5\n"
menuStr += "Type:Vertical,.....\n"
menuStr += "Panel=SubMenu2\n"
menuStr += "!Title Item\n"
menuStr += "Item 6\n"
menuStr += "Item 7"

/* End of ASP generated script */

</script>

<script language="JavaScript" src="options/dynamiclib.js"></script>
<script language="JavaScript"> ez_codePath = "../code/" </script>
<script language="JavaScript">
document.write("<SCR" + "IPT SRC='" + ez_codePath + "ezloader.js'><\/SCR" + "IPT>"); </script>
<script language="JavaScript">menusGo()</script>

<script> showPermPanel('MainBar', 20, 25) </script>

....Your Own HTML Code....

</BODY>

The lines in bold are the additional lines required for implementing the dynamic menu. The bold italicised lines define the menu and can be generated by scripts such as ASP or PHP. "dynamiclib.js" contains the code required to convert menuStr into EZmenu arrays. This file can be found in the "helpfiles/options/" subdirectory of the download.