• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 4. Handling a Fuseaction > Section 7: Root fbx_settings.cfm

Section 7: Root fbx_settings.cfm

We left the processing of our page request between sections 6 and 7 of the core file fbx_fusebox30_CF50.cfm. Section 7 is where we will start. It looks like this:

  <cfinclude template="fbx_Settings.cfm"> 
    <cfif fusebox.suppressErrors> 
      <cfoutput>The Fusebox framework could not find the file fbx_Settings.cfm...</cfoutput><cfabort> 


We already discussed the error handling in the core file in the previous chapter, so forget about everything from the first <cfcatch> to the last </cftry>. That leaves a remarkably slim section:

<cfinclude template="fbx_settings.cfm"> 

This does just what it looks like: It includes the root fbx_settings.cfm file. By “root,” we mean the folder from which the core file is being run. For example, if you are running the core file from your web root (c:\inetpub\wwwroot), then it will look for the fbx_settings.cfm file alongside it, in c:\inetpub\wwwroot.

Now the core has included two files: fbx_circuits.cfm (first) and fbx_settings.cfm (second).

Exactly what should go into the root fbx_settings.cfm file? Remember that this file is the first user-created file that has been processed, after fbx_circuits.cfm. Not only is fbx_settings.cfm the first file to be processed, but it is also the file that is processed with every page request, regardless of the fuseaction or circuit that is requested. The core file has not done anything specific to a fuseaction so far. That means that anything you want to be run with every page request should go in this file.

This sounds like ColdFusion’s Application.cfm file, doesn’t it? Remember though that Application.cfm has already been processed and that Fusebox discourages using it for anything other than file redirection. (Check out Chapter 14, “Construction and Coding,” to see why using Application.cfm is not a good idea). This means that the root fbx_settings.cfm file can assume some of the responsibilities that Application.cfm has in traditional ColdFusion applications.

Here is the root fbx_settings.cfm file for our example site, thirdwheelbikes.com:

<cfparam name="attributes.fuseaction" default="home.main"> 
<cfset xfa=structNew()> 
<cfset request.dsn="thirdwheelbikes"> 
<cfif fusebox.IsHomeCircuit> 
  <cfapplication name="thirdwheelbikes" clientmanagement="Yes" sessionmanagement="No" setclientcookies="No" clientstorage="#request.dsn#"> 
  <cfif not IsDefined("cookie.cfid")> 
    <cfcookie name="CFID" value="#client.cfid#"> 
    <cfcookie name="cftoken" value="#client.cftoken#"> 


Exactly what you put in the root fbx_settings.cfm file for your application is up to you. For the most part, this file can serve as a replacement for Application.cfm. However, because each circuit gets its own fbx_settings.cfm file, the code in the root fbx_settings.cfm should only be code that must be run for every fuseaction, regardless of the circuit.

Only one line is required in the root fbx_settings.cfm file:

<cfparam name="attributes.fuseaction" default="[circuit.fuseaction]"> 

This line creates a default fuseaction for the entire web site. The value circuit.fuseaction should be replaced with the actual circuit and fuseaction to be defaulted. As of this point in the processing of the core file (section 7), the variable fuseaction that was passed in on the URL string (&fuseaction=reviews.read) has been copied to the attributes scope. Therefore, the variable attributes.fuseaction has been created, and this line of code will not overwrite the fuseaction. This <cfparam> is needed if no fuseaction is passed.

Doesn’t the variable fuseaction have to be passed on each request? Yes it does, but look what happens if the user types in a URL like this:


No fuseaction is passed. The application responds with the default fuseaction, which is set in the root fbx_settings.cfm.

Now that the root fbx_settings.cfm file has been included, we can be assured that the variable attributes.fuseaction has been declared. The next section takes over here.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint