MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 176

Developing coldfusion mx applications
Table of Contents

Advertisement

Attribute Description (continued)
name
Required if the
identify a subdirectory under the CustomTags root directory.
Example:
GetUserOptions.cfm in the CustomTags\MyApp directory under the ColdFusion root
directory.
attributes The custom tag's attributes.
For example, the following code specifies to execute the custom tag defined by the mytag.cfm
page in the parent directory of the calling page:
<cfmodule template="../mytag.cfm">
For more information on using the
Calling custom tags using the cfimport tag
You can use the
following example imports the tags from the directory myCustomTags:
<cfimport prefix="mytags" taglib="myCustomTags">
Once imported, you call the custom tags using the prefix that you set when importing, as the
following example shows:
<mytags:customTagName>
where customTagName corresponds to a ColdFusion application page named
customTagName.cfm. If the tag takes attributes, you include them in the call:
<mytags:custom_tag_name attribute1=val_1 attribute2=val_2>
You can also include end tags when calling your custom tags, as the following example shows:
<mytags:custom_tag_name attribute1=val_1 attribute2=val_2>
...
</mytags:custom_tag_name>
ColdFusion calls the custom tag page twice for a tag that includes an end tag: once for the start
tag and once for the end tag. For more information on how ColdFusion handles end tags, and
how to write your custom tags to handle them, see
One of the advantages to using the
your custom tags to organize them by category. For example, you can put all security tags in one
directory, and all interface tags in another. You then import the tags from each directory and give
them a different prefix:
<cfimport prefix="security" taglib="securityTags">
<cfimport prefix="ui" taglib="uiTags">
...
<security:validateUser name="Bob">
...
<ui:greeting name="Bob">
...
Reading your code becomes easier because you can identify the location of your custom tags from
the prefix.
176
Chapter 9: Creating and Using Custom CFML Tags
attribute is not used. Use period-separated names to uniquely
template
<cfmodule name="MyApp.GetUserOptions">
cfmodule
tag to import custom tags from a directory as a tag library. The
cfimport
cfimport
identifies the file
tag, see CFML Reference.
"Handling end tags" on page
tag is that you can define a directory structure for
183.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents