Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Tags ?? 1

Status
Not open for further replies.

Bramvg

IS-IT--Management
Jan 16, 2001
135
BE
Hi,

Most likely a stupid question, but I read so mucht about custom tags, but does anyone know a link how I can create custom tags?

Or an example would be nice. An online manual how to create them would be superb of course.

tnx in advance!
bram
 
Check out this PDF file. It appears to have a pretty good tutorial on custom tags.
A good way to learn about custom tags is to download a few and learn by example. Custom tags are no different from regular CFML. The main trick is learning how to pass variables back and forth from custom tags. I'll give a really simple example for you.

The calling program:
<cf_MakeName FirstName=&quot;John&quot; LastName=&quot;Doe&quot;>
<cfoutput>
#FullName#
</cfoutput>

The custom tag (MakeName.cfm):
<cfset Caller.FullName = Attributes.FirstName & &quot; &quot; & Attributes.LastName>

As you can see, you can specify any variables you want when you call the tag and then reference them inside the tag. When you reference them from inside the tag they need the prefix of Attributes. To pass a variable back, assign the variable using the prefix of Caller. The custom tag can do anything you want it to, including screen output or calling of another custom tags. It can even call itself. Just make sure you copy the tag onto the server into the cfusion/Custom Tags directory.

Good luck! Just remember that custom tags are really nothing more than an intimidating name and after your first one you'll go &quot;Oh, I get it!&quot; |-0 Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top