dominoGuru.com
Your Development & Design Resource
Dynamic Web Menus via View Content
11/19/2003 02:31 PM by Chris Toohey
The other day Mike Golding turned me on to Dynamic Drive's Switcher Menu. I personally use Brainjar's Revenge of the Menu Bar and thought that I could use the configuration documents and display views to build out both of these "on the fly" while allowing me to dynamically control exactly what is contained within each "menu bar" or how many "menu bars" my application has.
The following is a brief breakdown on the example database that I built!
Using the below form, we entered some information into the form called contentbuilder which we would use as the basis for each "menubar". A simple category field, a multi-value text field to store the links and we had all that would be needed to populate the "menubar".
Now that we have the actual menu information, it was time to build the menus themselves.
For my index.html example (seen in the database), I simply created a view called "Menus.html" and created a category with this formula:
"<div class=\"menutitleindex\" onclick=\"SwitchMenu('" + Category +
"')\"><img src=\"foldopen.gif\" align=absmiddle> " + Category +
"</div>" + @NewLine + "<span class=\"submenuindex\" id=\"" + Category +
"\">" + @NewLine + @NewLine + @Implode("<a href=\"" + Links + "\"
target=\"_blank\">" + Links + "</a><br />") + @NewLine + @NewLine +
"</span>" + @NewLine + "</div>"
Now, I just added a $$ViewBody field to the $$NavigatorTemplate for index.html form, set it to "Computed for Display" for "Menus.html" and I had my quick navigator!
Since the document contains the Category and Links information, all I need to do is use that information in the view column to create the menu that I want!
Download the example database via the link below to see just what I'm talking about!