Chapter 7: Reusing Code
73
About Custom Tags in CFML
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 re-use while offering off-the-shelf solutions to many
programming chores.
An online RealVideo title called "Creating Custom Tags" is available at the Allaire Alive
section of our Web site. It presents an overview of custom tags as a component
architecture for the emerging Web platform and outlines the creation and use of CFML
custom tags.
Using Existing Custom Tags
Before creating a custom tag in CFML, you will probably want to visit the Custom Tag
section of the Allaire Developer Exchange at . Tags are grouped in several broad
categories and are downloadable as freeware, shareware, or commercial software. You
can quickly view each tag’s syntax and usage information. The Gallery contains a
wealth of background information on custom tags and an online discussion forum for
tag topics.
Tag names with the CF_ preface are CFML custom tags; those with the CFX_ preface
are ColdFusion Extensions written in C++. For more information about the CFX tags,
see Chapter 18, “Building Custom CFAPI Tags,” on page 275.
If you don't find a tag that meets your specific needs, you want to create your own
custom tags in CFML.
Writing Custom CFML Tags
Writing a custom tag in CFML is no different from writing any CFML template. You can
use all CFML constructs, as well as HTML.
Custom tags are stored either in the current directory or under the
customtags
directory. You call them using the CF_ prefix. Beyond that, 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. For example, the tag name
CF_getweather invokes the file
getweather.cfm
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, the
CFMODULE element provides a solution.
Note
While tag names in templates are case-insensitive, custom tag file names
must be lower case on UNIX.
Summary of Contents for COLDFUSION 4.5-DEVELOPING WEB
Page 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Page 14: ...xiv Developing Web Applications with ColdFusion...
Page 26: ...xxvi Developing Web Applications with ColdFusion...
Page 34: ...8 Developing Web Applications with ColdFusion...
Page 70: ...44 Developing Web Applications with ColdFusion...
Page 84: ...58 Developing Web Applications with ColdFusion...
Page 114: ...88 Developing Web Applications with ColdFusion...
Page 148: ...122 Developing Web Applications with ColdFusion...
Page 174: ...148 Developing Web Applications with ColdFusion...
Page 208: ...182 Developing Web Applications with ColdFusion...
Page 244: ...218 Developing Web Applications with ColdFusion...
Page 274: ...248 Developing Web Applications with ColdFusion...
Page 288: ...262 Developing Web Applications with ColdFusion...
Page 300: ...274 Developing Web Applications with ColdFusion...
Page 350: ...324 Developing Web Applications with ColdFusion...
Page 362: ...336 Developing Web Applications with ColdFusion...