pbm233 wrote: I created a cffunction in application.cfm, but I find I can't call it from other cfm files. I have application variables that I created and I can reference those, but trying to call the function gives me a "not found" error. I'm sure this is a scoping problem that I don't understand. How should I declare or reference the function to make it globally available? |
No special declarations or references are needed. Calling the function on any page within the scope of the application file should work.
To verify this yourself, do the following test. Create a directory and place the files Application.cfm and testPage.cfm in it.
Application.cfm
<cfapplication name="cftest"
sessionmanagement="Yes"
setclientcookies="Yes"
sessiontimeout="#createTimeSpan(0,0,60,0)#"
applicationtimeout="#createTimeSpan(1,0,0,0)#">
<cffunction name="f" returntype="string" >
<cfreturn "This string is the result of a function call in Application.cfm">
</cffunction>
testPage.cfm
<cfoutput>#f()#</cfoutput>
Now, run the test page. I expect the string to be output. My guess is that it failed in your case because you named your file application.cfm instead of Application.cfm.