I truly thought this project would be the end of me. The project was to create a CSS menu that pops up instead of down. Simple enough. However, when the user clicked on a child item, that menu tree had to stay open. If you’re at all familiar with CSS menus you know that they basically revolve around an unordered list with several classes and they turn the display property in CSS on and off. Of course, this wouldn’t work because the use of :hover was out. So, here’s how I accomplished this (2 level menus only)…
1) Create a custom nav class based on the generic. mine neiNav.
2) Keep track of where you are in the navigation tree. In my case I was using 2 levels only. The first level was a child of Home and the 2nd level was a child of any particular item in the first level. Since the point is to keep the child menu open if the user selects something from it, we only need to keep track of the object ID in the 2nd level. I did this with the following:
<cfparam name="parentNavID" default="">
<cfif application.factory.otree.getparentID(request.navid).parentid NEQ application.navid.home>
<cfset parentNavID = application.factory.oTree.getParentID(request.navid).parentId>
</cfif>
This way we know that if the parentNavID has a value, then the value it contains represents a level 1 menu item. Thus, the tree directly following this item needs to stay open
(more…)