Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 214

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
When ColdFusion processes the page containing this tag, it could output the message:
December 5, 1987 is Ted Cantor's Birthday.
Please wish him well.
A custom tag can also have a body and end tag, for example:
<cf_happybirthdayMessge name="Ellen Smith" birthDate="June 8, 1993">
<p> Happy Birthday Ellen!</p>
<p> May you have many more!</p>
</cf_happybirthdayMessge>
This tag could output the message:
June 8, 1993 is Ellen Smith's Birthday.
Happy Birthday Ellen!
May you have many more!
For more information about using end tags, see
Creating and calling custom tags
You implement a custom tag with a single ColdFusion page. You then call the custom tag from a ColdFusion page by
inserting the prefix
before the page's filename. The page that references the custom tag is referred to as the calling
cf_
page.
Create a ColdFusion page, the custom tag page, that shows the current date:
1
<cfoutput>#DateFormat(Now())#</cfoutput>
Save the file as date.cfm.
2
Create a ColdFusion page, the calling page, with the following content:
3
<html>
<head>
<title>Date Custom Tag</title>
</head>
<body>
<!--- Call the custom tag defined in date.cfm --->
<cf_date>
</body>
</html>
Save the file as callingdate.cfm.
4
5
View callingdate.cfm in your browser.
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 not case sensitive, 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
"Handling end
tags" on page 217.
Last updated 1/20/2012
209

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents