80
Developing Web Applications with ColdFusion
Example: Ancestor data access
This example was snipped from a custom tag.
<CFIF thisTag.executionMode is ’start’>
<!--- Get the tag context stack
The list will look something like
"CFIF,MYTAGNAME..." --->
<CFSET ancestorList = getBaseTagList()>
<!--- Output your own name because CFIF is
the first element of the tag context stack --->
<CFOUTPUT>
I’m custom tag #ListGetAt(ancestorlist,2)#<P>
</CFOUTPUT>
<!--- Determine whether you’re nested inside a loop --->
<CFSET inLoop = ListFindNoCase(ancestorList,’CFLOOP’)>
<CFIF inLoop neq 0>
I’m running in the context of a CFLOOP tag.<P>
</CFIF>
<!--- Determine whether you are nested inside
a custom tag. Skip the first two elements of the
ancestor list, i.e., CFIF and the name of the
custom tag I’m in --->
<CFSET inCustomTag = ’’>
<CFLOOP index=elem
list=#ListRest(ListRest(ancestorList))#>
<CFIF (Left(elem, 3) eq ’CF_’)>
<CFSET inCustomTag = elem>
<CFBREAK>
</CFIF>
</CFLOOP>
<CFIF inCustomTag neq ’’>
<!--- Say you are there --->
<CFOUTPUT>
I’m running in the context of a custom
tag named #inCustomTag#.<P>
</CFOUTPUT>
<!--- Get the tag instance data --->
<CFSET tagData = getBaseTagData(inCustomTag)>
<!--- Find out the tag’s execution mode --->
I’m located inside the
<CFIF tagData.thisTag.executionMode neq ’inactive’>
template because the tag is in
its start or end execution mode.
<CFELSE>
body
</CFIF>
<P>
Summary of Contents for COLDFUSION 4.5-DEVELOPING WEB
Page 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Page 14: ...xiv Developing Web Applications with ColdFusion...
Page 26: ...xxvi Developing Web Applications with ColdFusion...
Page 34: ...8 Developing Web Applications with ColdFusion...
Page 70: ...44 Developing Web Applications with ColdFusion...
Page 84: ...58 Developing Web Applications with ColdFusion...
Page 114: ...88 Developing Web Applications with ColdFusion...
Page 148: ...122 Developing Web Applications with ColdFusion...
Page 174: ...148 Developing Web Applications with ColdFusion...
Page 208: ...182 Developing Web Applications with ColdFusion...
Page 244: ...218 Developing Web Applications with ColdFusion...
Page 274: ...248 Developing Web Applications with ColdFusion...
Page 288: ...262 Developing Web Applications with ColdFusion...
Page 300: ...274 Developing Web Applications with ColdFusion...
Page 350: ...324 Developing Web Applications with ColdFusion...
Page 362: ...336 Developing Web Applications with ColdFusion...