
223
DEVELOPING
COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
Las
t
upda
te
d 8/5/2010
Create the first custom tag page
1
Create a ColdFusion page with the following content:
<cf_nesttag2>
2
Save the page as nesttag1.cfm.
Create the second custom tag page
1
Create a ColdFusion page with the following content:
<cfif thisTag.executionmode is 'start'>
<!--- Get the tag context stack. The list looks something like
"MYTAGNAME, CALLINGTAGNAME, ..." --->
<cfset ancestorlist = getbasetaglist()>
<!--- Output your own name. You are the first entry in the context stack. --->
<cfoutput>
<p>I'm custom tag #ListGetAt(ancestorlist,1)#</p>
<!--- Output all the contents of the stack a line at a time. --->
<cfloop index="loopcount" from="1" to="#listlen(ancestorlist)#">
Ancestorlist entry #loopcount# n is #ListGetAt(ancestorlist,loopcount)#<br>
</cfloop><br>
</cfoutput>
<!--- Determine whether you are nested inside a custom tag. Skip the first
element of the ancestor list, i.e., the name of the custom tag I'm in. --->
<cfset incustomtag = ''>
<cfloop index="elem"
list="#listrest(ancestorlist)#">
<cfif (left(elem, 3) eq 'cf_')>
<cfset incustomtag = elem>
<cfbreak>
</cfif>
</cfloop>
<cfif incustomtag neq ''>
<!--- Say that you are there. --->