Well, someone told me they heard the word “structure” get thrown around a lot in coldfusion, but they weren’t really clear on what it was. I thought i’d write a VERY basic overview of structures and coldfusion for those who don’t have the luxury of better-informed-colleagues to ask.
Ok, so you know how you can read variables in coldfusion, right? Well, just to be thorough, let’s review by getting the “oid” from the url:
url: website.com?oid=124
<cfoutput>#url.oid#</cfoutput>
And you get:
124
Easy peasy, right? now for those of you that don’t know, “url.oid” is, like many coldfusion variables, a STRUCTURE. Here are some other examples of structures just so we are clear:
#url.status#
#form.runadd#
#cart.items.sku#
So, in it’s most dumbed down form, it’s just a variable name with some dots thrown in the middle to make them easier to sort, like looking through a list of lists.
Did you know there are some structures available for you to use on EVERY page? YES! EVERY page! And they are super-helpful. Don’t believe me? try running this on any coldfusion page:
<cfdump var="#application#"> <cfdump var="#session#"> <cfdump var="#cgi#">
So, see all that craziness that gets dumped out? those are structures! how do you call one of the things you see… like this:
<cfoutput>#cgi.http_server#</cfoutput>
and there’s your http server’s name. excellent! Hopefully this will arm you with the ability to call just about anything you can dump.
Tags: 101, Coldfusion, structure