View callingdate.cfm in your browser.
5
This custom tag returns the current date in the format DD-MMM-YY.
As you can see from this example, creating a custom tag in CFML is no different from writing any
ColdFusion page. You can use all CFML constructs, as well as HTML. You are free to use any
naming convention that fits your development practice. Unique descriptive names make it easy
for you and others to find the right tag.
Note: Although tag names in ColdFusion pages are case-insensitive, custom tag filenames must be
lowercase on UNIX.
Storing custom tag pages
You must store custom tag pages in any one of the following:
•
The same directory as the calling page
•
The cfusion\CustomTags directory
•
A subdirectory of the cfusion\CustomTags directory
•
A directory that you specify in the ColdFusion MX Administrator
To share a custom tag among applications in multiple directories, place it in the
cfusion\CustomTags directory. You can create subdirectories to organize custom tags. ColdFusion
searches recursively for the Custom Tags directory, stepping down through any existing
subdirectories until the custom tag is found.
You might have a situation where you have multiple custom tags with the same name. To
guarantee which tag ColdFusion calls, copy it to the same directory as the calling page. Or, use
the
tag with the
cfmodule
more information on
Calling custom tags using the cfmodule tag
You can also use the
cfmodule
custom tag page. The
when invoking a custom tag, or if the application must use a variable to dynamically call a custom
tag at runtime.
You must use either a
following table describes the basic
Attribute Description
template
Required if the
This attribute:
• Specifies a path relative to the directory of the calling page.
• If the path value is prefixed with "/", ColdFusion searches directories explicitly mapped
in the ColdFusion MX Administrator for the included file.
Example:
<cfmodule template="../MyTag.cfm">
directory.
attribute to specify the absolute path to the custom tag. For
template
, see the next section.
cfmodule
tag to call custom tags if you want to specify the location of the
tag is useful if you are concerned about possible name conflicts
cfmodule
or
attribute in the tag, but you cannot use both. The
template
name
cfmodule
attribute is not used. Same as the
name
attributes:
template
identifies a custom tag file in the parent
attribute in cfinclude.
Creating custom tags
175
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