CFMODULE  
Description

Invokes a custom tag for use in ColdFusion application pages. This tag processes custom tag name conflicts.

 
Category

Application framework tags

 
Syntax
    <cfmodule template = "template"
   name = "tag_name"
   attributeCollection = "collection_structure"
   attribute_name1 = "valuea"
   attribute_name2 = "valueb"
   ...>

  
 
See also

cfapplication, cfassociate, cfauthenticate, cflock

 
Usage

To name a ColdFusion page that contains the custom tag definition, including its path, use the template attribute. To refer to the custom tag in the ColdFusion installation directory, using a dot notation scheme to indicate its location, use the name attribute.

You can use attributeCollection and attribute_name in the same call.

Within the custom tag code, the attributes passed with attributeCollection are saved as independent attribute values, with no indication that they are grouped into a structure by the custom tag's caller.

Similarly, if the custom tag uses a cfassociate tag to save its attributes, the attributes passed with attributeCollection are saved as independent attribute values, with no indication that they are grouped into a structure by the custom tag's caller.

 
Example
<!--- This example shows the use of cfmodule --->
<html>
<head>
<title>cfmodule Example</title>
</head>
<body>
<h3>cfmodule Example</h3>

<p>This example shows use of cfmodule to call sample custom tag inline.
</p>
<p>This example uses a sample custom tag that is saved in myTag.cfm in 
the snippets directory. You can also save ColdFusion custom tags 
in the Cfusion\CustomTags directory. For more information, see
<i>Developing Web Applications</i>.</p>
<!--- show the code in the custom tag--->   
<p>Here is the code in the custom tag.</p>
<cfoutput>#HTMLCodeFormat("<cfset x = attributes.x>
<cfset y = attributes.y>
<cfset a = attributes.value1>
<cfset b = attributes.value2>
<cfset c = attributes.value3>
<cfset caller.result = x + y + a + b + c>")#
</cfoutput>
<!--- end sample tag --->

<cfset attrcollection1 = structnew()>
<cfset attrcollection1.value1 = 22>
<cfset attrcollection1.value2 = 45>
<cfset attrcollection1.value3 = 88>

<!--- Call the tag with cfmodule with Name--->
<cfmodule 
  template = "..\snippets\myTag.cfm"
   x = "3"
   attributeCollection = #attrcollection1# 
   y = "4">

<!--- show the code --->
<p>Here is one way in which to invoke the custom tag, 
using the template attribute.</p>
<cfoutput>#HTMLCodeFormat(   "<cfmodule
   template = ""..\snippets\mytag.cfm""
   x = 3
   attributeCollection = ##attrcollection1##
   y = 4>")#
</cfoutput>   
<p>The result: <cfoutput>#result#</cfoutput> </p>   

<!--- Call the tag with cfmodule with Name--->
<cfmodule 
  name = "myTag"
   x = "3"
   attributeCollection = #attrcollection1# 
   y = "4">

<!--- show the code --->
<p>Here is another way to invoke the custom tag, 
using the name attribute.</p>
<cfoutput>#HTMLCodeFormat(   "<cfmodule
   name = 'mytag'
   x = 3
   attributeCollection = ##attrcollection1##
   y = 4>")#
</cfoutput>   
<p>The result: <cfoutput>#result#</cfoutput>   

<!--- Call the tag using the short cut notation --->
<cf_mytag 
   x = "3" 
   attributeCollection = #attrcollection1# 
   y = "4">
   
<!--- show the code --->   
<p>Here is the short cut to invoking the same tag.</p>
<cfoutput>#HTMLCodeFormat(   "<cf_mytag 
   x = 3 
   attributeCollection = ##attrcollection1## 
   y = 4>")#
</cfoutput>   
<p>The result: <cfoutput>#result#</cfoutput></p>   

</body>
</html>
TEMPLATE  
  Required
 

Used in place of the name attribute. A path to the page that implements the tag.

  • Relative path: expanded from the current page
  • Absolute path: expanded using ColdFusion mapping

A physical path is not valid.

NAME  
  Required
 

Used in place of the template attribute. A custom tag name, in the form "Name.Name.Name..." Identifies subdirectory, under the ColdFusion tag root directory, that contains custom tag page. For example (Windows format):

<cfmodule name = "macromedia.Forums40.
GetUserOptions">

This identifies the page GetUserOptions.cfm in the directory CustomTags\macromedia\Forums40 under the ColdFusion root directory.

ATTRIBUTECOLLECTION  
  Optional
 

Structure. A collection of key-value pairs that represent attribute names and values. You can specify multiple key-value pairs. You can specify this attribute only once.

ATTRIBUTE_NAME  
  Optional
 

Attribute for a custom tag. You can include multiple instances of this attribute to specify the parameters of a custom tag.