[Top] [All Lists]

Re: cfinclude question

Subject: Re: cfinclude question
From: "jdyerjdyer"
Date: Wed, 8 Aug 2007 06:42:30 +0000 UTC
Newsgroups: macromedia.coldfusion.cfml_general_discussion

function getRelativeDir(newdir)
        var curr = GetBaseTemplatePath();
        var rel = Right(newdir,Len(newdir)-3);
        var i = 1;
        for (i=1; i LT ListLen(curr,'\'); i=i+1)
                rel = "..\#rel#";
        return rel;

 I use this function any time I am unsure of the path a file is going to be 
called from.  So say the working directory is C:\wwwroot\somefolder and the 
file you want to include is C:\wwwroot\include\myfile.cfm
 Just pass C:\wwwroot\include\myfile.cfm into the function, it will always 
generate a relative path.
 Say you wanted to just get a relative path to the folder, just pass in 
 Now for the example working folder above you would get back 

 This function will also work for url references too, with a little trick.
 It ignores the first three letters (for file path this is the C:\)
 so say you have the webpage\myfolder\myfile.cfm and an image 
 You would pass in the **\img  the **\ is ignored, and the path passed back is 

<Prev in Thread] Current Thread [Next in Thread>