• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Get Calling Template Directory from CFC

Does anyone know how to get the directory path of the calling cfm file in a CFC?

If I use this statement to call a CFC from say this cfm file...  c:\websites\mysite\index.cfm

<cfset projects = CreateObject('Component','cfc.projects')>

The following code in the CFC file then tells me that the directory is "c:\websites\mysite\cfc\", but what I want is "c:\websites\mysite\".

<cfcomponent displayName="projects">
    <cfset this.rootdirectory = getfilefrompath(gettemplatepath())>

Any suggestions?
  • 2
1 Solution

try looking at the http.path_info or http.path_translated variables.
goldentineAuthor Commented:
Those variables return the name of the template that the web browser is currently on, not the page that actually called the CFC...
I think you might have to caclulate that and pass it into the component then. I dont think there is away to get information about what/who called the component.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now