MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual page 199

Table of Contents

Advertisement

Using Custom Tags
Reviewing the code
The following table describes the code and its function:
Code
<cfset NameYouEntered="Smith">
<cfoutput>
Before you leave this page,
you're
</cfoutput>
<CF_GetMD
Name="#NameYouEntered#">
<cfparam name="Attributes.Name"
default="Who">
<cfset Caller.Doctor="Doctor " &
Attributes.Name>
<cfoutput>
You are now
#Variables.Doctor#.<br>
</cfoutput>
Tip
Be careful not to overwrite variables that might already exist on the calling page. You
should adopt a naming convention to minimize the chance of overwriting variables.
For example, prefix the returned variable with customtagname_, with
customtagname being the name of the custom tag.
Note
Data pertaining to the HTTP request or to the current application is visible in the
custom tag page. This includes the variables in the Form, Url, Cgi, Request, Cookies,
Server, Application, Session, and Client scopes.
#NameYouEntered#.<br>
Description
In the calling page, create a variable
NameYouEntered and assign it the value
"Smith."
In the calling page, display the value of the
NameYouEntered variable before calling
the custom tag.
In the calling page, call the GetMD custom
tag and pass it the Name attribute whose
value is the value of the local variable
NameYouEntered.
The custom tag page normally gets the
Name variable in the Attributes scope from
the calling page. Assign it the value "Who"
if the calling page did not pass an attribute.
In the custom tag page, create a variable
called Doctor in the Caller scope so it will
exist in the calling page as a local variable.
Set its value to the concatenation of the
string "Doctor " and the value of the
Atributes.Name variable.
In the calling page, display the value of the
Doctor variable returned by the custom tag
page. (We use the Variables scope prefix
to emphasize the fact that the variable is
returned as a local variable.)
179

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION 5-DEVELOPING and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Coldfusion 5

Table of Contents