Here is a simplified version of the FuseBox framework written in ColdFusion code. It is especially useful if your headers and footers tend to vary a lot; which the formal framework does not handle gracefully.
[-------- FILE: index.cfm ----------]
<!---
************************************************************
*
* "Lite" version of Fusebox framework. This version has less
* indirection than the "formal" version and is far less code.
*
************************************************************
--->
<!--- Local Settings --->
<CFPARAM NAME="traceOn" DEFAULT="False"> <!--- useful for debugging --->
<CFPARAM NAME="pageTitle" DEFAULT="Sample Application">
<CFPARAM NAME="DSN" DEFAULT="myDSN"> <!--- data set name --->
<CFPARAM NAME="defaultFuseAction" DEFAULT="intro">
<!--- --->
<cfset fusebox = structNew()>
<!--- Get fuseaction from either url or form --->
<cfif isDefined('url.fuseaction')>
<cfset fusebox.fuseaction = url.fuseaction>
<cfelseif isDefined('form.fuseaction')>
<cfset fusebox.fuseaction = form.fuseaction>
<cfelse>
<cfset fusebox.fuseaction = defaultFuseAction>
</cfif>
<cfif traceOn> <!--- Output to HTML comment --->
<!-- TRACE: using fuseaction: <cfoutput>#fusebox.fuseaction#</cfoutput> -->
</cfif>
<cfinclude template="fbx_Utils.cfm"> <!--- optional --->
<cfinclude template="fbx_Switch.cfm">
[-------- FILE: fbx_Switch.cfm ----------]
<!---
Module: fbx_Switch.cfm
--->
<CFSWITCH EXPRESSION = "#fusebox.fuseaction#">
<CFCASE value="intro"> <!--- example entry --->
<cfinclude template="dsp_std_header.cfm">
<cfinclude template="dsp_navigation.cfm">
<cfinclude template="dsp_std_footer.cfm">
</CFCASE>
<CFDEFAULTCASE>
<!---This will just display an error message and is
useful in catching typos of fuseaction names while
developing--->
<CFOUTPUT>
<li>Received UNDEFINED fuse-action called
"#fusebox.fuseaction#" Please notify information services.
<!--- custom stuff --->
<hr>
<a href="#fbxUrl('intro')#">Launch Main Page</a>
<!--- end custom stuff --->
</CFOUTPUT>
</CFDEFAULTCASE>
</CFSWITCH>
[-------- FILE: fbx_utils.cfm ----------]
<!--- Example Utility Function (optional) --->
<cffunction name="fbxUrl" output="No">
<!--- Create a typical fuse-action call. Wrapped in a function to make
conversion to other FB frameworks easier.
Append URL parameters to result as needed. Example: fbxUrl('foo') & '&bar=7'
Note that this may not work in POST mode.
--->
<cfargument name="p_fuseaction" default="">
<cfset var result=''>
<cfset result = 'index.cfm?fuseaction=' & trim(p_fuseaction)>
<cfreturn result>
</cffunction>
[------end--------]
Notes:
-
You may want to put the settings into a "fbx_Settings.cfm" file to stick with Fuse-Box conventions.
-
A convention to try is to have "inc_x.cfm" files to group commonly-used include files. It creates a kind of set-based grouping in contrast to the hierarchical approach that circuits tend to use. Tree-skeptics may dig it. However, those who feel that all include files should be directly visible in the switch list file may balk. It is a kind of information-hiding-versus-transparency debate. An alternative that may be more palatable to Fuse-box fans is to keep the list(s) in the same Switch file, but as a subroutine (supported in Cold-Fusion version 6 and up). That keeps all the Include files listed in one place.
-
A wiki bug may mess the line spacing in the above in some browsers. Grab the text from wiki EDIT mode instead.
CategoryLowEnd, CategoryFramework