> No, Patrick, I don't think it's a good idea...
>
> I messed with the idea of having multi-part fuseactions to reflect the
> hierarchy of the app.  My CF_AddCircuits tag built all of the hierarchical
> request.circuit data, and then you had to use some real ugly
> evaluate() code
> to reference anything (because you have to take into account your
> relationship to the current home app, right?).

No need for evaluate() code.

Every time a layer is peeled off and we move down to the next circuit,
the variable ctx would be updated. So if grandparent is my home app,
ctx would be set to 'parent' and then to 'parent.child'.

So if I have the following code in child:
<cflocation url="#self#?fuseaction=#ctx#.dosomething">
I'll relocate to
/grandparent/index.cfm?fuseaction=parent.child.dosomething

If parent is the home app, the same code would relocate to
/grandparent/parent/index.cfm?fuseaction=child.dosomething

And if child is itself the home app...
/grandparent/parent/child/index.cfm?fuseaction=.dosomething

The code to do this is simpler than Hal's.
-------------------------------------------------

<cfparam name="ctx" default="">

<!---
  (code you want to be 'inherited')
--->

<!---
  if the home app calls itself, there will be no context,
  and your fuseaction will have an extraneous '.' at the beginning,
  so get rid of it
--->
<cfif left(attributes.fuseaction,1) eq '.'>
  <cfset attributes.fuseaction =
right(attributes.fuseaction(len(attributes.fuseaction-1))>
</cfif>

<!---
  take the first item off fuseaction, make it the last item
  in ctx, and move down to the next directory
--->
<cfif findNoCase(attributes.fuseaction, '.')>
  <cfset nextCircuit = listFirst(attributes.fuseaction, '.')>
  <cfset attributes.fuseaction = listRest(attributes.fuseaction, '.')>
  <cfset ctx = listAppend(ctx, nextCircuit, '.')>
  <cfinclude template="#nextCircuit#/index.cfm">
</cfif>

-------------------------------------------------

I completely left out the circuits.cfm because it's not really
necessary if we're using the "fully qualified fuseaction," but
we could add it back in if there's some advantage in doing so.
<cfinclude template="circuits.cfm">

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

Reply via email to