Fun question. I have been mulching on this for a while now, and here is
my *current* "solution":
In Application.cfm:
<cfscript>
sttCFG = StructNew();
sttCFG.strAppPhysDir = GetDirectoryFromPath(GetCurrentTemplatePath());
// sttCFG.strAppPhysDir = GetDirectoryFromPath(ExpandPath("..\"));
sttCFG.strBasePhysDir = GetDirectoryFromPath(GetBaseTemplatePath());
// sttCFG.strBasePhysDir = GetDirectoryFromPath(ExpandPath("scripts/"));
sttCFG.nLenAppPhysDir = Len(sttCFG.strAppPhysDir);
sttCFG.nLenBasePhysDir = Len(sttCFG.strBasePhysDir);
sttCFG.strBaseWebRelPath = Reverse(ListRest(Reverse(CGI.SCRIPT_NAME),
"/")) & "/";
sttCFG.nLenBaseWebRelPath = Len(sttCFG.strBaseWebRelPath);
if (sttCFG.nLenAppPhysDir EQ sttCFG.nLenBasePhysDir) {
sttCFG.strAppWebRelPath = sttCFG.strBaseWebRelPath;
} else {
sttCFG.strAppWebRelPath = Left(sttCFG.strBaseWebRelPath,
sttCFG.nLenBaseWebRelPath - (sttCFG.nLenBasePhysDir -
sttCFG.nLenAppPhysDir));
}
</cfscript>
<cfdump var="#sttCFG#">
--------------------------------
BIG ASSUMPTION:
NO VIRTUAL FOLDERS under the approot. :P
Note:
The two commented out lines were for testing purposes. :P And the code
is intentionally verbose. You can optimize, and obfuscate however you
like. :)
----------------------------
James Ang
Programmer/Product Engineer
MedSeek, Inc.
[EMAIL PROTECTED]
-----Original Message-----
From: Barney Boisvert [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 21, 2003 11:45 AM
To: CF-Talk
Subject: RE: easy path question
That's a nasty problem, because the Application.cfm file might not be in
the
same directory as the base template, because CF looks up the directory
tree
until it finds one. I think you'll want to start with cgi.script_name
and
getBaseTemplatePath() in your base template. The compute the part of
the
full path that'd different from the script_name, and then compare that
to
the response getCurrentTemplatePath(), and see what's different. Then
you
can apply those differences to cgi.script_name to compute the URL to
Application.cfm. That assumes that if you call getBaseTemplatePath()
from
Application.cfm, that it will return the template path of the actual
requested page, but that might not be the case.
barneyb
> -----Original Message-----
> From: Smith, Matthew P -CONT(DYN)
[mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 21, 2003 11:33 AM
> To: CF-Talk
> Subject: easy path question
>
>
> I'd like to have an expression in Application.cfm that tells me
> the path to
> the current site, basically the web path to the directory
> Appication.cfm is
> in.
>
> So if we are in c:\interpub\wwwroot\subSite\Application.cfm
>
> And I call
>
> http://myserver.com/subSite/subdirectory/subsubDirectory/page.cfm
> <http://myserver.com/subSite/subdirectory/subsubDirectory/page.cfm>
>
> I would have a var available in Application.cfm that resolves to:
>
> /subSite/
>
> Hmm, seemed simple but I'm not explaining it well... Basically
> the web path
> to Application.cfm, so I can set it to a var and append it like:
>
> #sitePath#subdirectory/subsubDirectory/page.cfm
>
> As the site may be moved to different directories.
>
> I know it's doable but mixing all the getBaseTemplateScriptNamePath
> functions gets tricky for me.
>
> Thanks!
>
> Matthew P. Smith
> Web Developer, Object Oriented
> Naval Education & Training Professional
> Development & Technology Center
> (NETPDTC)
> (850)452-1001 ext. 1245
> [EMAIL PROTECTED]
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4