I have a page that I use cfc's on. Like this:
<cfset cfcDashboard = new dashboard()>
<cfset grab_image = cfcdashboard.getPicture()>
How do I call the cfc's if they are inside of a folder? As of right now they only work if they are on the same level or inside the same folder? How do you call a cfc that is on a different level?
Or am I not understanding the purpose of the cfc?
The new
keyword is syntactic sugar for this call:
<cfset cfcDashboard = createObject("component", "Dashboard")>
The rules how ColdFusion resolves CFC names are in the docs.
If you use a
cfinvoke
orcfobject
tag, or theCreateObject
function, to access the CFC from a CFML page, ColdFusion searches directories in the following order:
- Local directory of the calling CFML page
- Web root
- Directories specified on the Custom Tag Paths page of ColdFusion Administrator
You can use dot notation that corresponds to any of the defined search paths.
<cfset myDashboard = createObject("component", "my.custom.Dashboard")>
<cfset myDashboard = new my.custom.Dashboard()>
Will find (where .
means the current template directory and /
means the web root):
./my/custom/Dashboard.cfc
/my/custom/Dashboard.cfc
any/custom/tag/path/my/custom/Dashboard.cfc
Going "up" is not possible.