Copy link to clipboard
Copied
I would like to use the following UDF on several sites. How do I register the UDF with Coldfusion and Dreamweaver so the tag is useable without including the UDF on every page?
The following throws an error.
#titleCaseList("blah blah blah"," ")#
UDF:
Copy link to clipboard
Copied
You have to save the udf code somewhere on your own server first. Your choices are:
a. a .cfc file or
b. a .cfm file
either can serve as a function library and either can contain more than just that function.
If you use option b, you have to cfinclude the template. If you use option a, you'll have to either create an object or use cfinvoke to run the function.
Copy link to clipboard
Copied
You can include the UDF in Application.cfm thus making it available on
every page or you can include the UDF in a separate file (for example
lib.cfm) and include that in your Application.cfm or the actual pages
where you want to use the function. I tend to define UDF's in separate
files (lib_admin.cfm, lib_user.cfm, lib_validation.cfm) and include
the files in Application.cfm.
Mack
Copy link to clipboard
Copied
There is no way to "register" a UDF so that it can be called by any code. the UDF must be included in any file that attempts to make use of it.
Some common approaches are to create UDF function libary(ies) that can be included when desired with the <cfinclude...> line and|or to include UDF library(ies) with all templates by inserting the UDF, or relevant <cfinclude...> reference to the UDF file, in either the Application.cfm or Application.cfc files.
Copy link to clipboard
Copied
So there is no way to make the UDF a "custom tag" so that it doesn't have to be included on every page, via Application.cfm or other means?
When a new version of CF comes out, Adobe also releases an update to Dreamweaver that updates the Tag Libraries and whatnot. Can I do this same thing but with the UDF?
Copy link to clipboard
Copied
You can make it a custom tag by taking the basic logic of the function, and rewriting the surrounding code so that it works as a custom tag.