setting system wide variable based on an environment variable

29 views
Skip to first unread message

Mike Henke

unread,
Jan 29, 2010, 12:34:44 PM1/29/10
to ColdFusion on Wheels
Here is a discussion for background of where I am coming from:
http://groups.google.com/group/cfwheels/browse_thread/thread/1ef535c08674a4e3/481ef70991537518

----

A variable that needs to be set into the set only once but is based on
an environment variable. I am putting it into each /environment/
settings.cfm file but it doesn't seem DRYsince I repeat the same code
in each environment settings.cfm file.

example of /config/design/settings.cfm

<cfset loc.myapp.site = "http://testwww.thissite.com">

<!--- this gets repeated exactly in each settings.cfm since it --->
<cfhttp url="#get('myapp').site#/banner_main.inc" result="header1" />
<cfset loc.myapp.header1 = acfheader1.Filecontent>

<cfhttp url="#get('myapp').site#/banner_main.inc" result="header2" />
<cfset loc.myapp.header2 = acfheader2.Filecontent>

<cfhttp url="#get('myapp').site#/banner_main.inc" result="header3" />
<cfset loc.myapp.header3 = acfheader3.Filecontent>


Any ideas how to dry this? I tried a partial but the function isn't
available yet. I also tried setting in the config/settings.cfm but
the environment/settings.cfm hasn't ran yet.

tpet...@gmail.com

unread,
Jan 29, 2010, 1:20:29 PM1/29/10
to ColdFusion on Wheels
funny how there's another thread about this issue :)

http://groups.google.com/group/cfwheels/browse_thread/thread/306ac9de56749be2

what you can do, setup default in your config/settings:

<cfset loc.myapp.site = "http://testwww.thissite.com">

<!--- this gets repeated exactly in each settings.cfm since it --->
<cfhttp url="#get('myapp').site#/banner_main.inc" result="header1" />
<cfset loc.myapp.header1 = acfheader1.Filecontent>

<cfhttp url="#get('myapp').site#/banner_main.inc" result="header2" />
<cfset loc.myapp.header2 = acfheader2.Filecontent>

<cfhttp url="#get('myapp').site#/banner_main.inc" result="header3" />
<cfset loc.myapp.header3 = acfheader3.Filecontent>

<cfset set(myapp = loc.myapp)>

then in your config/design/settings you can do:

<cfset loc.myapp = get("myapp")>
<cfset loc.myapp.site = "http://example.com">
<cfset set(myapp = loc.myapp)>

only over riding the variables that you need in each environment.

On Jan 29, 12:34 pm, Mike Henke <henkem...@gmail.com> wrote:
> Here is a discussion for background of where I am coming from:http://groups.google.com/group/cfwheels/browse_thread/thread/1ef535c0...

Reply all
Reply to author
Forward
0 new messages