Fuse Box Lite

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#" &nbsp; 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:


CategoryLowEnd, CategoryFramework


EditText of this page (last edited September 11, 2008) or FindPage with title or text search