The following example accesses the
within a custom tag:
<cfif thisTag.ExecutionMode is 'start'>
Handling end tags
The examples of custom tags shown so far in this chapter all reference a custom tag using just a
start tag, as in:
<cf_date>
In this case, ColdFusion calls the custom tag page date.cfm to process the tag.
However, you can create custom tags that have both a start and an end tag. For example, the
following tag has both a start and an end tag:
<cf_date>
...
</cf_date>
ColdFusion calls the custom tag page date.cfm twice for a tag that includes an end tag: once for
the start tag and once for the end tag. As part of the date.cfm page, you can determine if the call is
for the start or end tag, and perform the appropriate processing.
ColdFusion will also call the custom tag page twice if you use the shorthand form of an end tag:
<cf_date/>
You can also call a custom tag using the
<cfmodule ...>
...
</cfmodule>
If you specify an end tag to
start and an end tag.
Determining if an end tag is specified
You can write a custom tag that requires users to include an end tag. If a tag must have an end tag
provided, you can use
included the end tag.
For example, in date.cfm, you could include the following code to determine whether the end tag
is specified:
<cfif thisTag.HasEndTag is 'False'>
<!--- Abort the tag--->
<cfabort showError="An end tag is required.">
</cfif>
Determining the tag execution mode
The variable
thisTag.ExecutionMode
The variable has one of the following values:
•
Start
Mode for processing the start tag.
•
End
Mode for processing the end tag.
ExecutionMode
cfmodule
, then ColdFusion calls your custom tag as if it had both a
cfmodule
thisTag.HasEndTag
contains the mode of invocation of a custom tag page.
variable of the
tag, as shown in the following example:
in the custom tag page to verify that the user
structure from
thisTag
Executing custom tags
183
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers