Application Level Vars

20 views
Skip to first unread message

rob_parkhill

unread,
Jan 29, 2010, 12:22:20 PM1/29/10
to ColdFusion on Wheels
Good Day,

Just looking at the documentation for layouts and I see that you can
define your variables, but that that they need to be defined in each
controller to exist in the page. I was looking at the title var in
particular, and wondering how to access the site name that I set up in
the config file. I would much rather be able to access that via the
layout as opposed to needing to define it in each controller.

Maybe I am just missing it though, sorry for the newbie question.

Rob

tpet...@gmail.com

unread,
Jan 29, 2010, 1:13:03 PM1/29/10
to ColdFusion on Wheels
take a look at the set() method

http://cfwheels.org/docs/function/set

what i usually do for my sites is setup a container called myapp in
the global scope using set and put any application specific setting in
there so it doesn't collide with any wheels settings:

in config/settings

<cfset loc.myapp = {}>
<cfset loc.myapp.title = "this is my site">
<cfset set(myapp = loc.myapp)>

then to retrieve them, you use the get() method

http://cfwheels.org/docs/function/get

so within my view, controllers or models i do:

<cfset myapp = get("myapp")>

<cfoutput>#myapp.title#</cfoutput>

or if you prefer:

<cfoutput>#get("myapp").title#</cfoutput>

rob_parkhill

unread,
Jan 29, 2010, 1:31:14 PM1/29/10
to ColdFusion on Wheels
Perfect, that was what I was looking for.

Thanks!

Rob

tpet...@gmail.com

unread,
Jan 29, 2010, 1:46:09 PM1/29/10
to ColdFusion on Wheels
my pleasure.

mike henke also asked a similar question. my response in this thread

http://groups.google.com/group/cfwheels/browse_thread/thread/644af7786038d95

Mike Henke

unread,
Jan 29, 2010, 3:28:15 PM1/29/10
to ColdFusion on Wheels
Should this solution be in the Wheels docs?

Rob Parkhill

unread,
Jan 29, 2010, 3:36:48 PM1/29/10
to cfwh...@googlegroups.com
I did look around the docs for a reference to an Application level variable, or how to create a controller to deal with them, and I saw nothing that made sense at the time.  

I will +1 this to the docs.

Rob

Mike Henke

unread,
Jan 29, 2010, 3:44:52 PM1/29/10
to ColdFusion on Wheels

Chris Peters

unread,
Jan 30, 2010, 11:07:22 AM1/30/10
to cfwh...@googlegroups.com
This convinces me that moving the "Working with Wheels" section to the 2nd spot will help beginners out. If you think about it, you use the Introduction section to get installed and a jumpstart on how to use the framework. Then getting a crash course on conventions and configurations would probably be the next best step.

All of that info about conventions and configurations was buried at the bottom, and we get a ton of questions about those chapters.

Let's keep things simple instead of writing a chapter for every little scenario. It's a balance. I'll watch for more related questions and figure out what we're missing, if anything.

On Fri, Jan 29, 2010 at 3:44 PM, Mike Henke <henk...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.


Reply all
Reply to author
Forward
0 new messages