Calling non fusebox cfm templates when using Fusebox 5.5’s Application.cfc
I’ve just encountered a problem where I wanted to run a non fusebox cfm script outside of Fusebox. If you use the Application.cfc supplied with Fusebox5.5, then it will route all requests to a cfm template through Fusebox regardless of what the template is called. As no fuseaction was specified, it just loaded the start page of my Fusebox app in the browser.
For example in my webapp root I have Application.cfc, index.cfm (both as supplied in the Fusebox 5.5 download) and another script called cgi_dump.cfm which just contains <cfdump var=”#cgi#” />. Calling cgi_dump.cfm in your browser will load the fusebox app.
One solution for this would be to put my non fusebox script in a sub folder with it’s own Application.cfc or Application.cfm which works but is a bit annoying. Rather than go for the simple solution, I had to work out a way for this to happen!
My hack for this is to edit the Application.cfc and add an onRequest method:
<cffunction name="onRequest">
<cfargument name="targetPage" type="string" required="true" />
<cfif ListLast(arguments.targetPage, "\/") eq myFusebox.getSelf()>
<cfset super.onRequest(arguments.targetPage) />
<cfelse>
<!--- Include the requested page. --->
<cfinclude template="#arguments.targetPage#" />
</cfif>
</cffunction>
This checks to see the name of the called template against the known fusebox ‘hub’ template (usually index.cfm). Just to make sure that myFusebox.getSelf() is set to “index.cfm” (which it won’t be if the fusebox app hasn’t been run before), then add the FUSEBOX_PARAMETER:
// force fusebox to only run if this script is called
FUSEBOX_PARAMETERS.self = "index.cfm";
To stop the Fusebox debugging, you’ll need to also add the onRequestEnd method to your Application.cfc.
<!--- not part of the Fusebox Application.cfc --->
<cffunction name="onRequestEnd">
<cfargument name="targetPage" type="string" required="true" />
<cfif ListLast(arguments.targetPage, "\/") eq myFusebox.getSelf()>
<!--- Pass request to Fusebox. --->
<cfset super.onRequestEnd(arguments.targetPage) />
</cfif>
</cffunction>
- Posted in:
- ColdFusion
- Fusebox


Comment by Seth – May 02, 2008
I've just tested this against the fusebox skeleton apps (noxml and traditional) and can't replicate the error. Feel free to send me your code and I'll try it out.
Comment by John Whish – May 03, 2008
Comment by Seth – May 03, 2008
You're welcome, glad you got it working!
Comment by John Whish – May 04, 2008
If it makes any difference, I'm using the no xml version
Comment by Will Wilson – August 05, 2009
Comment by John Whish – August 05, 2009
Here is the debugging :
Including fusebox.init.cfm
Compiling requested fuseaction 'app.welcome'
Implicit component-as-circuit controller/app.cfc identified
Parsed file 'app.welcome.cfm' is unchanged and was not overwritten
Implicit circuit view/layout-v/ identified
Parsed file 'do.layout-v.lay_template.cfm' is unchanged and was not overwritten
<do action="layout-v.lay_template"/> -- dynamic Request failed with exception 'Expression' (Variable BODY is undefined.)
Comment by Will Wilson – August 05, 2009
How do you fix this error?
Comment by kurt – June 27, 2011