Calling Custom Tags

There is no real installation process for custom tags other than to save them on your ColdFusion server. There are, however, different locations on the server where you can save the tags that affect whether they can be called locally by a single application or shared across all applications.

To call a custom tag from within a CFML template, you simply prefix the template name of the tag with cf_. Therefore, if you have a custom tag saved on your server as mytag.cfm, you call it like this:

<cf_mytag>

When you call a custom tag from an application template, ColdFusion looks for the tag in the same directory as the calling template. For example, if your template resides in \inetsrv\wwwroot\myapp and tries to call a custom tag called cf_mytag, ColdFusion looks for the tag in the \myapp directory first. Saving a custom tag in the same directory as its calling template makes the tag a local tag. That is, the tag is available only to templates residing in the same directory as the application. Using the local-tag technique allows you to use custom tags in hosted environments where you might not have access to a shared custom tags directory.

The very nature of custom tags makes them ideal for sharing among multiple applications on the server. In order to facilitate this, a default custom tags directory is automatically created when you install ColdFusion on your server. This directory is \cfusionmx\customtags by default. Any custom tags saved in this directory or ...

Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.