CFLib.org – Common Function Library Project

GetRootPath()

Last updated October 3, 2002

author

Billy Cravens

Version: 1 | Requires: CF5 | Library: UtilityLib

Description:
It's pretty common to need to root path of an application (for redirects, images, etc.) Typically, this value is hard-coded. This UDF allows you to dynamically determine the root path. Note: this requires that the template calling this UDF is in the root directory.

Return Values:
Returns a string.

Example:

<cfoutput>#getRootPath()#</cfoutput>

Parameters:

No arguments.

Full UDF Source:

/**
 * Determines the root path of the application without hard-coding.
 * 
 * @return Returns a string. 
 * @author Billy Cravens (billy@architechx.com) 
 * @version 1, October 3, 2002 
 */
function GetRootPath() {
	var cNested = listLen(getBaseTemplatePath(),"\") - listLen(getCurrentTemplatePath(),"\");
	var	appRootDir = cgi.script_name;
	var i = 0;
	
	for (i=0;i lte cNested;i=incrementValue(i)) {
		appRootDir = listDeleteAt(appRootDir,listLen(appRootDir, "/"),"/");
	}
	appRootDir = appRootDir & "/";
	return appRootDir;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson