Frequently Asked Questions

Help Center Search

What are ColdFusion custom tags and how do I use them?

Print this Article
Comment on this Article
Last Updated: February 19, 2007 8:55 AM

Custom tags are a way of encapsulating your code so that you can use it on other ColdFusion pages just like a standard CFML tag.

For example, you could create a customer tag called "cf_hello" as follows:

  1. First, build a page named hello.cfm with the following code:
    <cfoutput> Hello#Attributes.Name#! </cfoutput>

  2. Now, build another page called myapp.cfm (and place it in the same directory as hello.cfm) with the following code:
    <cf_hello Name="Joe User">
    Welcome to my Website!

  3. Browse to myapp.cfm and you will see the results:
    Hello, Joe User!
    Welcome to my Website!

NOTE: If you plan to use your custom tags across multiple ColdFusion pages in several different directories, you are better off calling your tag using <cfmodule>. This way, you won't have to have a copy of your custom tag page in every directory of your site. For example, the following code will call the custom tag in the parent directory:

<cfmodule template="/hello.dfm" Name="Joe User">

Currently, we do not support the creation of mappings, nor the installation of ColdFusion tags in the cffusionCustom Tags directory on the server.

For more info on using custom tags, see Macromedia's Livedocs site at Macromedia's livedocs website