I'm doing a major update to my personal little application framework. The original was begun in CF 3.0, updated heavily when 4.5 came out and is now being updated for 5/MX.
One thing I do is set several variables in Application.cfm like so: <!--- This is the offset from webroot to application.cfm. An application at the root would use a slash, an application in the directory "MyApp" would use "/MyApp/ ---> <cfset Request.AppRootOffset = "/"> <!--- Set Application Path for Custom Tags ---> <cfset Request.AppPath = GetDirectoryFromPath(GetCurrentTemplatePath())> <!--- Get Path information ---> <cfset Request.RootPath = ReplaceNoCase(GetDirectoryFromPath(GetBaseTemplatePath()), GetDirectoryFromPath(GetCurrentTemplatePath()), "")> <cfset Request.RelRootPath = REReplaceNoCase(Request.RootPath, "[^\]*\\", "../", "All")> So, with that, if Request.AppRootOffset = "/DepressedPress/" and the current template is "/DepressedPress/Content/ColdFusion/Index.cfm" then this might be the result (results will vary with web server configuration): Request.AppPath = "D:\WWWRoot\VBoston.com\DepressedPress\" Request.RootPath = "/DepressedPress/Content/ColdFusion/" Request.RelRootPath = "../../" Similarly all custom tags have this code to let them find assets in the same folder as they are (for example a navigation tags graphical assets would be in the same folder as the custom tag): <!--- Set Paths for Tag ---> <cfset TagPath = ReplaceNoCase(GetDirectoryFromPath(GetCurrentTemplatePath()), Request.AppPath, "")> <cfset TagRelRootPath = REReplaceNoCase(TagPath, "[a-z_-]*\\", "../", "All")> <!--- Swap slashes for use in HTML ---> <cfset TagPath = Request.AppRootOffset & Replace(TagPath, "\", "/", "All")> <cfset TagRelRootPath = Replace(TagRelRootPath, "\", "/", "All")> Using these variables means that I can move applications around within the web root, to new servers, etc and only have to change the hard coded value of "Request.AppRootOffset" Now I've already converted all of that stuff to UDFs (although I do have one small regex difference between 4.5/5 and MX that requires server version conditional processing) and everything's working. However the fact still remains that I still need to hardcode my "RootOffset" value and add the UDF call to every custom tag. I'd like to determine a way to eliminate those needs if at all possible. How do you folks do this (or am I making things just too damn difficult)? I'm not looking for "how to" help - I'm looking for "how should" help. ;^) I think that I may be able to calculate the Root OffSet using the CGI variables (CF_TEMPLATE_PATH and SCRIPT_NAME specifically) but I'm not sure how I possibly do the custom tags (I think that I'll have to live with that). I'm working (for various projects) all versions of CF back to 4.01, but the biggies are all on MX or 5 now so I'd like to keep this applicable to at least those two. So, unfortunately, no CFCs (yet). Thanks in advance, Jim Davis President, http://www.depressedpress.com Webmaster, http://www.firstnight.org Webmaster, http://www.cfAdvocacy.org Senior Consultant, http://www.metlife.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| 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 Host with the leader in ColdFusion hosting. Voted #1 ColdFusion host by CF Developers. Offering shared and dedicated hosting options. www.cfxhosting.com/default.cfm?redirect=10481 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4