CFLib.org – Common Function Library Project

GetHTTPDir([pathType])

Last updated October 9, 2001

author

Spike

Version: 1 | Requires: CF5 | Library: FileSysLib

Description:
Retrieves the url for the current directory in full or relative format. Depends on cgi.server_name and cgi.script_name variables.

Return Values:
Returns a string.

Example:

<STRONG>Full Format:</STRONG><BR>
<CFOUTPUT>#GetHTTPDir('full')#</CFOUTPUT>
<BR>
<BR>
<STRONG>Relative Format:</STRONG> <BR>
<CFOUTPUT>#GetHTTPDir('relative')#</CFOUTPUT>
<BR>
<BR>
<STRONG>Default Format:</STRONG> <BR>
<CFOUTPUT>#GetHTTPDir()#</CFOUTPUT><BR>
<BR>
<STRONG>Invalid Parameter:</STRONG><BR>
<CFOUTPUT>#GetHTTPDir('part')#</CFOUTPUT>

Parameters:

Name Description Required
pathType Format to return the path in. Valid values are 'full' and 'relative'. Returns the text string 'invalid paramter' if the parameter is not 'full' or 'relative'. Default value for the parameter is 'relative'. No

Full UDF Source:

/**
 * Retrieves the url for the current directory in full or relative format.
 * 
 * @param pathType 	 Format to return the path in.  Valid values are 'full' and 'relative'.  Returns the text string 'invalid paramter' if the parameter is not 'full' or 'relative'. Default value for the parameter is 'relative'.   
 * @return Returns a string. 
 * @author Spike (spike@spike.org.uk) 
 * @version 1, October 9, 2001 
 */
function GetHTTPDir() {
        var format = "";
	if (arraylen(arguments)) {
	 format = arguments[1];
		if (format EQ 'full') {
			return "http://#cgi.server_name##listDeleteAt(cgi.script_name,listlen(cgi.script_name,'/'),'/')#/";
		}
		else if (format EQ 'relative') {
			return "#listDeleteAt(cgi.script_name,listlen(cgi.script_name,'/'),'/')#/";
		}
		else {
			return 'invalid argument';
		}
	}
	else {
		return "#listDeleteAt(cgi.script_name,listlen(cgi.script_name,'/'),'/')#/";
	}
}
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