質問

I'm trying to create basically a library of UDFs (User Defined Functions) for a web site run in ColdFusion. While doing this I am trying to find out what the differences are between cfc and cfm files. Which would be more helpful in creating this library of functions? I know that I can use

<cfinclude template="mytemplate.cfm>

to include it in a page but that will run the entire contents of that cfm on that page every time. I don't know and easier way to use cfc other than to create an object of the cfc and call the function that way.

<cfobject type="component" action="create" name="test">

Any ideas?

役に立ちましたか?

解決

The way that I do it is to create all my UDF in a cfc. I then initialize that cfc on application start:

public function onApplicationStart() {
    // Application settings
    application.util = createObject("component","cfc.util");
    return;
}

他のヒント

use a cfc you can call more easily from more places, if its not too huge put it into your application scope

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top