Hi everyone,
I'm trying to use a structure to hold the navigation scheme for a site.
Unfortunately, the fact that "structure keys are unordered" as the livedocs
tell me, is causing a problem. Here's what I'm doing.
I use the addItem method of my CFC to add new items to my navigation.
<cfset addItem("Overview", "title.cfm")>
<cfset addItem("Table of Contents", "toc.cfm")>
<cfset addItem("Tasks", "tasks.cfm")>
<cfset addItem("Details", "details.cfm")>
<cfset addItem("Project Team", "team.cfm")>
addItem looks like so:
<cffunction name="addItem" displayName="Add Item" hint="I add a navigation
item to a navigation block." access="public" returnType="boolean"
output="false">
<cfargument name="LinkName" type="string" required="true">
<cfargument name="PageName" hint="The .cfm page to link to"
type="string" required="true">
<cfset var local = StructNew()>
<cfset local.item = StructNew()>
<cfset StructInsert(local.item, arguments.LinkName,
arguments.PageName)>
<cfset setNavigation(local.item)>
<cfreturn true>
</cffunction>
setNavigation looks like this:
<cffunction name="setNavigation" access="private" returntype="VOID"
output="false">
<cfargument name="NavItem" type="struct" required="true" hint="A
structure containing the navigation item to add to the list">
<cfset StructAppend(variables.instance.navigation,
arguments.NavItem)>
</cffunction>
Variables.instance.navigation holds my navigation structure. Now,
considering the order in which I added my navigation items, I would expect
them to be spit out in the same order. Instead they come out like so:
Details, Table of Contents, Overview, Project Team, Tasks
Now, if structs really were unordered, I would expect that they would
occassionally come out in a *different* order, but nope... They always come
out in the same order, WRONG! :).
Anyone have any ideas to help me crack this nut?
Thanks,
Dan
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]