Invoking Components (CFCs) with a relative path

Posted by Dan on Nov 5, 2007 @ 4:21 PM

Back in March of 2003 I posted a UDF which allows you to initiate a CFC from a relative path. Anyway, since it's been over 4 years at 2 major releases of ColdFusion, I just wanted to let everyone know that this UDF does indeed still work in ColdFusion 8.

While it is a hack and I can't guarentee it won't cause server problems, I can say I've been using this in production code since I wrote the UDF and have never found a problem.

Categories: HTML/ColdFusion, Source Code

2 Comments

  • Not sure if this works in 8, but you can use 'relative pathing' directly in createObject() to instantiate a component. For example:

    <cfset obj = createObject("component","/mapping/some/path/to/MyComponent").init()>
  • @JAlpino:

    Relative pathing would allow you to do: "../../folder/component.cfc"

    This is still not natively supported, but the UDF I posted does work in CF8.

Add Comment

Leave this field empty