2

I have global function in my system that was implemented while ago before I even started maintaining the system. One of the recent projects involved some major updates in that function. I have set the cfmail with some information inside in hope that I will get the .cfm page that call that function. So far only that I got is the page where the function is located but I already knew that. I got this information with this function:

GetDirectoryFromPath(path)

I was wondering if there is any other function that can give me the name of the page that called the function? If anyone can help me solve this problem please let me know. I'm still doing research but there is nothing that I came accross that would be helpful in my case.

espresso_coffee
  • 5,980
  • 11
  • 83
  • 193

1 Answers1

1

I use CF9 and did this:

In a CFC

<cffunction name="dumpCGI" returntype="void" output="yes">
<cfdump var="#cgi#">
</cffunction>

In the calling template:

obj = createObject("component", "Something");
obj.dumpCGI();

I saw 3 variables that correctly identified the calling template. Once you pick the one you want to use, you can decide how to process it.

Dan Bracuk
  • 20,699
  • 4
  • 26
  • 43
  • I ended up using #CGI.HTTP_REFERER#. That gave me the template name. CGI in general gives you everything you need I guess. Thanks for your help! – espresso_coffee May 02 '17 at 13:53
  • I would have gone with path_translated, path_info, or cf_template_path. If you have a form or url that leads to the page calling the cfc, http_referrer will probably not be what you want. – Dan Bracuk May 02 '17 at 15:10
  • Only HTTP_REFERER gave the information about the page from where my function was called. path_translated just gave the page where cffunction is located that I already know. Path_Info is empty for some reason. I will keep looking if this will give me different information later on. – espresso_coffee May 02 '17 at 15:18
  • 1
    Your results were different than mine. I recommend that you test the scenario where the page calling the function is itself accessed by a form or hyperlink. – Dan Bracuk May 02 '17 at 16:09