>> -----Original Message-----
>> From: Will Tomlinson [mailto:[EMAIL PROTECTED]
>> Sent: Thursday, July 07, 2005 10:44 PM
>> To: CF-Talk
>> Subject: Including App.cfc in App.cfc
>>
>> If I have an Application.cfc in the site root, and it
>> contains an
>> APPLICATION.DSN variable, and there's an admin folder
>> with its own
>> App.cfc, how would I include the root's APP.DSN inside
>> the admin folder's
>> app.cfc?
>>
>> When I used App.cfm I just included the root App.cfm.
> Well... it is just a CFC. Can't you just CFINVOKE the
> other Application.cfc
> methods in the child one?
You could do that, or Tim recommended using a separate template and
using <cfinclude> in each applicaiton.cfc to set them... You would
just put the cfinclude tag in the onApplicationStart method. He also
suggested using the same application name in both cfc's which is fine,
but you still have to set or param the variable in both, so you would
still need the cfinclude template.
Alternately you could design something _like_ the onTap framework's
tiered request stages where you have a single Application.cfc which
sets the variables in the onApplicationStart method and variations
between the root application and the admin application are handled by
including code in multiple templates or directories in the
onRequestStart method.
<cffunction name="onRequestStart">
<cfset var x = 0>
<cfset var local = structnew()>
<cfset local.approot =
getDirectoryFromPath(getCurrentTemplatePath())>
<cfset local.targetpath =
getDirectoryFromPath(getBaseTemplatePath())>
<cfset local.target =
listtoarray(replace(local.targetpath,local.approot,""),"/\")>
<cfset local.path = "">
<cfset arrayprepend(local.target,"")>
<cfloop index="x" from="1" to="#arraylen(local.target)#">
<cfset local.path = listappend(local.path,local.target[x])>
<cfif FileExists(local.approot & local.path & "/settings.cfm")>
<cfinclude template="#local.path#/settings.cfm">
</cfif>
</cfloop>
</cffunction>
I've never considered this very complicated... although some people
have... anyway, this method (or something like it) would allow you to
have the equivalent of something like the old app_locals.cfm concept
without the need to include a template in each base template (like the
nested Application.cfm templates), since the single Application.cfc
would handle it for as many nested directories as you need.
s. isaac dealey 954.522.6080
new epoch : isn't it time for a change?
add features without fixtures with
the onTap open source framework
http://www.fusiontap.com
http://coldfusion.sys-con.com/author/4806Dealey.htm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:211413
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54