Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Archived Topics for the old Version 3.0 JavaScript Menu
Forum Topic: Click to view post
Last Updated: Wednesday July 18 2012 - 06:07:35

ColdFusion Tag


Poster: ghamm
Dated: Tuesday June 18 2002 - 7:34:54 BST

Hi all,

After playing with the menu for a little while, I do have to say wow (great work andy) And I have been reading about some CF tags and tried a few out (thanks matt and Robert) great tags but neither of them really fit the bill, I wanted a menu that could be pulled out of the DB with a recursive parent child relationship. so that each item had an ItemID and a parentID that related them.

I got something running on CF5 using Query of Queries (it now only hits the DB once instead of once for each menu item !!)

Stats:
first time the tag runs: 400-500ms (kinda slow I know--but better than the 3000-4000 I was getting initially)
subsequent times 100-140ms (not nearly as fast as Matt's)

I was hoping that since I am a student (only been playing with CF for a few months) that some of the more advanced CF coders on the site could take a look at it and give me some suggestions for improvement and optimization?

email me __at__ greg_hamm __at__ yahoo.com if you can help out.

Thanks everyone
greg

PS Andy, as soon as I get this tag going I am going to license a bunch of menus, cheers.


Poster: theking __at__ mysecretbase.com
Dated: Wednesday June 19 2002 - 18:04:11 BST

Hi Greg,

I'll take a look at it if you like. I'm a little confused, though. You say you want a heirarchical system that works with a standard item/parent ID structure. MenuMongerToo and MenuMonger Pro do precisely that, to an infinite level, or did I misunderstand your post?

How many menu items generated that execution time?

Be advised I went from CF 4.5 straight to CF MX, so I'm not totally up on query of queries, but maybe I can see something in there to speed up what you've got.

Feel free to contact me here or directly. You can just email me some snippets if you like.

Cheers,

Parent/Child menu from CF


Poster: racine
Dated: Friday June 21 2002 - 20:39:09 BST

I'm currently doing exactly what you're asking. What we do though to same on execution time is actually dynamicly write out a static file when ever a change to the menu has been made, therefore saving on CPU cycles by not having to 'create' a menu every visit.

I create a 'header.js' file with the basic stuff the menu needs for startup.
Then load my dyamic file (pullmenu4.cfm)
and finally load the mmenu.js

So in my main CF file it looks something like this:


<SCRIPT language="JavaScript" src="mmenuHeader.js" type="text/javascript"></SCRIPT>

<CFINCLUDE template="PullMenu4.cfm">

<SCRIPT language="JavaScript" src="mmenu3411.js" type="text/javascript"></SCRIPT>

working example: http://www.zomix.com/v3


Poster: theking __at__ mysecretbase.com
Dated: Friday June 21 2002 - 21:28:32 BST

I store my menu arrays in a big text field. The idea was to be able to swap in different menus, depending on the group permissions and privilege level of the given user running the system at that moment. However, the same thing can be accomplished as you describe.

I keep my different menu versions (I use 5) in a single db record, and cache the query to that record for 2 minutes. Keeps db traffic to a negligible level while still letting admins update the stored menu and see their results in a reasonable time.

Dynamicly Populating Menu from CF


Poster: racine
Dated: Friday June 21 2002 - 22:17:29 BST

I actually have a record for each menu entry. Each entry also has a parent id, 0 being the top level. With this information we can query the DB and extract the whole menu structure.

Example of our PullMenuCreate.cfm file (this creates a file called 'pullmenu4.cfm' that would be included in our main template)

<CFSET #Parents# = "">
<cfoutput query="AllNavigation" group="ParentID">
<CFSET #Parents# = "#Parents#,#AllNavigation.ParentID#">
</CFOUTPUT>

<cfoutput query="AllNavigation" group="ParentID">

<CFIF #ParentID# is not 0>
<CFFILE ACTION="APPEND"
FILE="#FullPath#\#PMAFile#" OUTPUT="addmenu(menu=[""menu#ParentID#"",,,#PullMenuSVOffset#,#PullMenuSBSize#,"""",prop2,0,""#PullMenuSHOffset#"",#PullMenuSIndent#,0,#PullMenuStVOffset#,#PullMenuSHSize#,""#PullMenuSMAlign#"",,,,""formstohide;formstohide2;"",,,,
">
</CFIF>

<cfoutput>
<CFSET #TheFullNav# = "
,""&nbsp;#NewNav#&nbsp;"",<CFIF #ListContains(Parents,InfoID)#>""show-menu=menu#InfoID#"",""<CFIF ##ShowAdmin## is ""Yes""><cfoutput>#FullURL###ADminDir##/Page.cfm?InfoID=#InfoID#</cfoutput><CFELSE>#FullURL#/#NavName#</CFIF>""<CFELSE>""<CFIF ##ShowAdmin## is ""Yes""><cfoutput>#FullURL###ADminDir##/Page.cfm?InfoID=#InfoID#</cfoutput><CFELSE>#FullURL#/#NavName#</CFIF>"",</CFIF>,,<CFIF #ParentID# is 0 and #PMMSepBorder# is not 0>#PMMSepBorder#<CFELSEIF #ParentID# is 0 and #PMMSepBorder# is 0>#PMSep#<CFELSEIF #PullMenuSHColor# is not 0>#PullMenuSHColor#<CFELSE>#PMSep#</CFIF>">

<CFFILE ACTION="APPEND" FILE="#FullPath#\#PMAFile#" OUTPUT="#TheFullNav#">
</cfoutput>

<CFFILE ACTION="APPEND" FILE="#FullPath#\#PMAFile#" OUTPUT="])">
</cfoutput>

<CFFILE ACTION="APPEND" FILE="#FullPath#\#PMAFile#" OUTPUT="
dumpmenus() // This must be the last line in this file
</SCRIPT>
">


Poster: theking __at__ mysecretbase.com
Dated: Friday June 21 2002 - 22:25:07 BST

I am a complete idiot...

Never occurred to me to use the GROUP attribute to eliminate the need for multiple queries when doing the admin-side build of the menu. Jeez... Can you say SQL 1A?

Thats what happens when you start going down one road, put blinders on and close your mind off to (ridiculously simple) alternatives as a result.

Thanks very much for the post. My builder will be a lot easier on my db as a result.