Invokes a custom tag for use in ColdFusion application pages. The cfmodule
tag can help deal with custom tag name conflicts.
Use the template
attribute to name a ColdFusion page that contains the custom tag definition, including its path. Use the name
attribute to refer to the custom tag using a dot notation scheme to indicate the location of the custom tag in the ColdFusion installation directory.
Web application framework tags
<cfmodule template = "template" name = "tag_name" attributeCollection = "collection_structure" attribute_name1 = "value" attribute_name2 = "value" ...>
cfapplication,
cfassociate,
cfauthenticate,
cflock
You can use attributeCollection
and attribute
in the same call.
Within the custom tag code, the attributes passed with attributeCollection
are saved as independent attribute values with no indication that the attributes were grouped into a structure by the custom tag's caller.
Likewise, 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 the attributes are grouped into a structure by the custom tag's caller.
<!--- This example shows the use of cfmodule ---> <html> <head> <title>cfmodule Example</title> </head> <body> <h3>cfmodule Example</h3> <p> This example shows the use of cfmodule to call a sample custom tag inline. </p> <p> This example makes use of a sample custom tag that has been saved in the file myTag.cfm in the snippets directory. You can also save ColdFusion custom tags in the Cfusion\CustomTags directory. For more information about using Custom Tags, please refer to <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>