User Guide

Using Custom Tags 173
6 Include the header.cfm file in this page:
<cfinclude template="header.cfm">
7 View askemp.cfm in a browser, then submit the form so that you display
getemp.cfm.
The header should appear on both pages.
Note
The file header.cfm must be in the same directory where you saved askemp.cfm and
getemp.cfm (or a subdirectory). If it is not, make sure it is in a directory that has a
mapping defined in ColdFusion Administrator, or move it to the appropriate
directory.
Using Custom Tags
Custom tags wrap functionality in a page that can be called from a ColdFusion
application page. ColdFusion custom tags built in CFML allow for rapid application
development and code reuse while offering off-the-shelf solutions to many
programming chores.
You use a custom tag just as you would use a standard HTML or ColdFusion tag, for
example, you might call a custom tag to generate a happy birthday message as
follows:
<CF_HappyBirthday name="Ted Cantor" birthDate="December, 5, 1987">
A custom tag can also have a body and end tag, for example:
<CF_HappyBirthdayMessge name="Ellen Janes" birthDate="June, 8, 1993">
<P> Happy Birthday Ellen!</P>
<P> May you have many more!</P>
</CF_HappyBirthdayMessage>
You call custom tags by adding the cf_ prefix to the filename (without the .cfm
suffix). For example, use the tag name
cf_getweather to call the file getweather.cfm.
You must store custom tags that you call directly in either the same directory as the
calling page, in the CFUSION\CustomTags directory, or in a subdirectory of the
CFUSION\CustomTags directory. Each file defines a single custom tag.
You can also use the
cfmodule tag to call custom tags. The cfmodule tag lets you
specify the location of the custom tag file. The
cfmodule tag is useful if you are
concerned about possible name conflicts when invoking a custom tag or if the
application must use a variable to dynamically call a custom tag at runtime. For
more information on using the
cfmodule tag, see theCFML Reference.