If boxed into a corner, I would do this:
<cfcase value="doSomething">
<cfinclude template="act_DoSomething.cfm">
<cfif isConditionTrue>
<cfinclude template="qry_aQuery.cfm">
</cfif>
</cfcase>
However, depending on the problem, I would
usually approach the problem a completely
different way.
A)
Break the fuseaction into two parts.
<cfcase value="doSomething">
<cfset xfa.isTrue = "doQuery">
<cfset xfa.isFalse = "skipQuery">
<cfinclude template="act_DoSomething.cfm">
<cflocation url="#self#?fuseaction=#xfa.condition#">
</cfcase>
<cfcase value="doQuery">
<cfinclude template="qry_aQuery.cfm">
...
</cfcase>
<cfcase value="skipQuery">
...
</cfcase>
B)
Put the condition inside the query file. It may
not necessarily amount to wrapping the entire
thing in a CFIF, but I'm not ruling out the
possibility.
C)
Combine the act_ and qry_ files into one.
D)
Throw an exception at the act_ file if the
condition isn't true.
E)
Include the qry_ file anyway. The performance
hit may not be worth worrying about.
F)
Write two different fuseactions, and move the
conditional logic one step back in the
workflow (if possible).
Question for you: What do you do after the
query? Obviously, there must be fuse following
that uses the query. Does that fuse include a
check to see whether the query actually
exists? If that was the case, I would look
for a simpler way to approach the problem.
Patrick
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists