Skip to main content
Participant
September 3, 2008
Question

using cflocation with variable in url

  • September 3, 2008
  • 3 replies
  • 1222 views
I am trying to create a custom tag that gets the name of the current template and then passes that name in a query string appended to a url in a cflocation tag.

<cfset temp=GetFileFromPath(GetBaseTemplatePath())>
<cflocation url="index.cfm?ref=#temp#">

When this page redirects, it determines "temp" to be "index.cfm" instead of whatever file was when the script was called. It appears to not process "temp" until after the cflocation.

Is there any way to get this to work?

This topic has been closed for replies.

3 replies

Inspiring
September 3, 2008
> You could always try caller.cgi.something. Maybe it'll work, maybe it'll crash.

CGI variables are global to the request, so there's no need for the
"caller" reference.

They're not specific to a CF template, as they're set by the web server,
which doesn't know anything about CF, which templates are called what,
which order they are called in or anything like that.

--
Adam
Inspiring
September 3, 2008
You could always try caller.cgi.something. Maybe it'll work, maybe it'll crash.
Inspiring
September 3, 2008
Are you sure you don't mean getCURRENTtemplatePath()?

--
Adam
keusteAuthor
Participant
September 3, 2008
Yes, I'm trying to get the filename of the original (base) template. I am using the script in a custom tag. If I use GetCurrentTemplatePath then it returns the filename of the custom tag (which is not what I expected -- I would expect it to be similar to GetBaseTemplatePath). I have tried GetBaseTemplatePath, CGI.CF_TEMPLATE_PATH, and CGI.SCRIPT_NAME. They all return the path of the file I am redirecting TO, not the file I am redirecting FROM.