lexo
asked on
Best practice to build a very large dynamic menu in coldfusion
What is the best practice to create a dynamic menu using coldfusion and javascript. I want the menu to call the db minimally and the menu must be able to branch out to several levels with onClick events. The menu must load fast as there will be several thousand pages, so I am thinking that maybe the menu query results get stored in a session value? I'm not sure if this is a good technique. A link to a tutorial will suffice to answer this question.
ASKER
Do you think that saving the data in a session variable like this is the best/fastest way to go?
much faster than not putting it in a session.
and as far as best practices -
if menu is always the same - meaning that one user sees the same menu as everyone else then I'd put it in the application scope
but if you have a members area (for ex) that is determined by a users login then it would need to be in a session
you'd setup a default menu to start and when and if user logs in then set their "session menu" is reset to whatever is applicable
and as far as best practices -
if menu is always the same - meaning that one user sees the same menu as everyone else then I'd put it in the application scope
but if you have a members area (for ex) that is determined by a users login then it would need to be in a session
you'd setup a default menu to start and when and if user logs in then set their "session menu" is reset to whatever is applicable
ASKER
Everyone would see the same menu, it is a public site.
Is this how it would be done?
<cfif Not StructKeyExists(applicatio n,"menuLis t")>
<cfquery ... >
select ...
</cfquery>
<cfsavecontent variable="menuContent">
put your code that builds menu inside here
</cfsavecontent>
<cflock scope="application" type="exclusive" timeout="15">
<cfset application.menuList=menuC ontent>
</cflock>
</cfif>
#application.menuList#
Is this how it would be done?
<cfif Not StructKeyExists(applicatio
<cfquery ... >
select ...
</cfquery>
<cfsavecontent variable="menuContent">
put your code that builds menu inside here
</cfsavecontent>
<cflock scope="application" type="exclusive" timeout="15">
<cfset application.menuList=menuC
</cflock>
</cfif>
#application.menuList#
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
<cfif Not StructKeyExists(session,"m
<cfquery ... >
select ...
</cfquery>
<cfsavecontent variable="menuContent">
put your code that builds menu inside here
</cfsavecontent>
<cflock scope="session" type="exclusive" timeout="15">
<cfset session.menuList=menuConte
</cflock>
</cfif>
#session.menuList#