Securing custom tags
The ColdFusion security framework enables you to selectively restrict access to individual tag files
and tag directories. This can be an important safeguard in team development. For details, see
Configuring and Administering ColdFusion MX.
Accessing existing custom tags
Before creating a custom tag in CFML, you should review the Custom Tag section of the
ColdFusion Developer Exchange at http://devex.macromedia.com/developer/gallery/index.cfm.
You might find a tag here that does what you want.
Tags are grouped in several broad categories and are downloadable as freeware, shareware, or
commercial software. You can 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
ColdFusion extensions written in C++. For more information about the CFX tags, see
12, "Building Custom CFXAPI Tags," on page
If you do not find a tag that meets your specific needs, you can create your own custom tags in
CFML.
Passing data to custom tags
To make your custom tags flexible, you will often want to pass data to them for processing. This
section describes how to write custom tags that take tag attributes and other data as input from a
calling page.
Passing values to and from custom tags
Because custom tags are individual ColdFusion pages, variables and other data are not
automatically shared between a custom tag and the calling page. To pass data from the calling
page to the custom tag, you can specify attribute name/value pairs in the custom tag, just as you
do for normal HTML and CFML tags.
For example, to pass the value of the NameYouEntered variable to the cf_getmd tag, you can call
the custom tag as follows:
<cf_getmd Name=#NameYouEntered#>
To pass multiple attributes to a custom tag, separate them with a space in the tag as follows:
<cf_mytag Firstname="Thadeus" Lastname="Jones">
In the custom tag, you use the Attributes scope to access attributes passed to the tag. Therefore, in
the getmd.cfm page, you refer to the passed attribute as
custom tag page refers to the passed attributes as
Attributes.Lastname
The custom tag page can also access variables set in the calling page by prefixing the calling page's
local variable with Caller. However, this is not the best way to pass information to a custom tag,
because each calling page would be required to create variables with the names required by the
custom tag. You can create more flexible custom tags by passing parameters using attributes.
preface are CFML custom tags; those with the
cf_
.
251.
Attributes.Name
Attributes.Firstname
Passing data to custom tags
preface are
cfx_
Chapter
. The mytag.cfm
and
177
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