문제

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