Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Register UDF/Custom Tag

Participant ,
Jul 06, 2009 Jul 06, 2009

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:

http://www.cflib.org/index.cfm?event=page.udfbyid&udfid=889

1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 06, 2009 Jul 06, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 06, 2009 Jul 06, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 06, 2009 Jul 06, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 06, 2009 Jul 06, 2009

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 06, 2009 Jul 06, 2009
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources