Someone in allaire's forums recently mentioned a problem I had been having
with the fusebox methodology. With help from members of this mailing list, I
came up with a solution and thought I'd share with you all my findings.

(not very complex, but there have been enough people asking for help)

==== 

Calling a Fusebox application as a tag (i.e. calling the index.cfm file
through cfmodule/cfinclude) can have advantages and disadvantages.

The main advantage is that you can encapsulate complex file management and
processes through the very simple tag structure that is built into
ColdFusion. So instead of trying to figure out what files are needed to do
some action, you simple need to know the path of the index.cfm file (i.e.
template="/directory/index.cfm") the fuseaction you want to call (i.e.
fuseaction=somefuseaction) and any other variables that are needed for that
specific fuseaction.

The main disadvantage is when dealing displays. For example if you include a
layout display file that contains a menu within your application, then call
that application from some parent application that already contains that
menu layout you'll end up with two menus on the page. Which is most likely
not what you want. 

    * http://forums.allaire.com/devconf/Index.cfm?Message_ID=572223

==== 

My solution is to modify the file "app_layout.cfm" to consider an attribute
called "attributes.displaylayout" which will default to "true".

As an "index.cfm" file (or fuse) executes normally, headers/footers in the
"app_layout.cfm" file are cfincluded just as they should be.

But when this same "index.cfm" file (or fuse) is called through a
<cf_module> tag, as such:

            <cfmodule template="index.cfm"
                displaylayout="false"
                fuseaction="test"
                >


...and the attribute "displaylayout" is passed as "false", then the
"app_layout.cfm" file will execute that request differently, only outputting
the variable "request.bodycontent" without and header/footer files being
cfincluded. By doing so, you avoid displaying duplicate headers/footers.

Perhaps this is all best explained by reading through the "app_layout.cfm"
code pasted below.

Hope this helps. 

Cheers!

-Russ

-- 
Russell Jones
Webmaster
ImproveNow.com
Phone: 207.236.0146
e-mail: [EMAIL PROTECTED]

=================================================
index.cfm
-------------------------------------------------

<cfinclude template="app_locals.cfm">

<cf_bodycontent>
    <cfswitch expression="#attributes.fuseaction#">
    
        <cfcase value="dothis">
            <!---Evaluate: Do This--->
        </cfcase>
        
        <cfcase value="dothat">
            <!---Evaluate: Do That--->
        </cfcase>
        
        <cfcase value="test">
            <hr>This is a test!<hr>
        </cfcase>  
        
        <cfdefaultcase>
            <cfinclude template="dsp_enter.cfm">
            <cfmodule template="index.cfm"
                displaylayout="false"
                fuseaction="test"
                >
        </cfdefaultcase>
        
    </cfswitch>
</cf_bodycontent>

<cfinclude template="/#request.cfroot#/app_layout.cfm">

=================================================
app_layout.cfm
-------------------------------------------------

<cfsetting enablecfoutputonly="yes">

    <cfparam name="request.headerfile">
    <cfparam name="request.footerfile">
    <cfparam name="request.bodycontent">
    <cfparam name="attributes.showbody" default="yes">
    <cfparam name="attributes.displaylayout" default="true">

<cfsetting enablecfoutputonly="no">

<!---handle displaylayout--->
<cfif attributes.displaylayout>
    <cfif len(request.headerfile)>
        <cfinclude template="#request.headerfile#">
    </cfif>
    <cfif attributes.showbody>
        <cfoutput>#request.bodycontent#</cfoutput>
    </cfif>
    <cfif len(request.footerfile)>
        <cfinclude template="#request.footerfile#">
    </cfif>
<cfelse>
    <cfif attributes.showbody>
        <cfoutput>#request.bodycontent#</cfoutput>
    </cfif>
</cfif>

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to