Hi All,
i've created a struct which when outputted, outputs in the 'wrong order'
If you run the code below when you're in a subdirectory, i.e:
/home/mydir1/mydir2/somepage.cfm
each dir and page name is added to the struct in order:
When I dump the struct, it comes out in the correct order, but when I loop it
as a collection, it comes out in a wierd order?
I know that structs don't have exact row numbering, but can anyone tell me why
the dump order is different to the actual outputted order?
Thanks
T
<cfsilent>
<cfscript>
//Create a struct to play with
Bread.struct=StructNew();
//Set our root location
currentlocale="/";
</cfscript>
<!---CGI.SCRIPT_NAME is the var with the current location in--->
<cfloop list="#cgi.SCRIPT_NAME#" delimiters="/" index="i">
<cfscript>
//Insert the looped value into the struct, replacing
underscores and .cfm
//The keyname becomes the URL, and the keyvalue is the
text to link
StructInsert(Bread.struct, "#currentLocale##i#",
"#replace(replace(i, '_', ' ', 'all'), '.cfm', '', 'all')#");
//Update currentlocale, which acts as the string to
update
currentlocale="#currentLocale##i#/";
</cfscript>
</cfloop>
</cfsilent>
<!---For demo purposes, dump the struct - note the order--->
<cfdump var="#bread#">
<!---Output the struct--->
<cfoutput>
<div>
<p>
<cfloop collection="#bread.struct#" item="i">
<cfoutput>
<a href="#i#">#bread.struct[i]#</a> >
</cfoutput>
</cfloop>
<p>
</div>
</cfoutput>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
The most significant release in over 10 years. Upgrade & see new features.
http://www.adobe.com/products/coldfusion?sdid=RVJR
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:277276
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4