80
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>
</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
<CFBREAK>
</CFLOOP>
<CFIF inCustomTag neq ''>
I'm running in the context of a CFLOOP tag.<P>
list=#ListRest(ListRest(ancestorList))#>
<CFIF (Left(elem, 3) eq 'CF_')>
<CFSET inCustomTag = elem>
</CFIF>
<!--- 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>
Developing Web Applications with ColdFusion
Need help?
Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?