Ticket #54 (closed enhancement: fixed)
FUSEBOX_CALLER_PATH for chained includes
| Reported by: | scorfield | Owned by: | scorfield |
|---|---|---|---|
| Type: | enhancement | Priority: | low |
| Milestone: | Fusebox 5.1 | Component: | Miscellaneous |
| Version: | 5.0 | Severity: | normal |
| Keywords: | Cc: |
Description
From Harry Klein:
My colleague suggested to add a fusebox parameter called
FUSEBOX_CALLER_PATH:
========================================================
Fusebox 5 sets "this.approotdirectory" wrong if the calling template
which includes the fusebox5.cfm (mostly index.cfm) is included by
another template which is in a different directory than the calling
template (index.cfm). This is because "this.webrootdirectory" is
calculated on the base template, which is in a different directory in
this case.
With the optional fusebox parameter FUSEBOX_CALLER_PATH we could force
the "this.approotdirectory".
Per default FUSEBOX_CALLER_PATH would be the same as the detection of
"this.webrootdirectory"
(#replace(getDirectoryFromPath(getBaseTemplatePath()),"\","/","all")#)
and Fusebox 5 would perform like before.
fusebox5.cfm
added line 58: <!--- FB5: caller path --->
added line 59: <cfparam name="FUSEBOX_CALLER_PATH" type="string"
default="#replace(getDirectoryFromPath(getBaseTemplatePath()),"\","/","a
ll")#" />
changed line 81:
from:
.init(FUSEBOX_APPLICATION_KEY,FUSEBOX_APPLICATION_PATH,myFusebox) />
to:
.init(FUSEBOX_APPLICATION_KEY,FUSEBOX_APPLICATION_PATH,myFusebox,FUSEBOX
_CALLER_PATH) />
fuseboxApplication.cfc
added line 88: <cfargument name="callerPath" type="string"
required="true"
added line 89: hint="I am FUSEBOX_CALLER_PATH." />
changed line 102:
from: <cfset this.approotdirectory = this.webrootdirectory &
replace(arguments.appPath,"\","/","all") />
to: <cfset this.approotdirectory =
replace(arguments.callerPath,"\","/","all") &
replace(arguments.appPath,"\","/","all") />
optional in index.cfm:
<!--- Force Fusebox 5 to set the appRootDirectory based on the location
of this template --->
<cfset FUSEBOX_CALLER_PATH =
getDirectoryFromPath(getCurrentTemplatePath())>
========================================================
What do you think about this idea?
