Copy link to clipboard
Copied
I need an idiot-proof way of determining the current path of the template I’m working with.
If I have a path C:\ColdFusion8\wwwroot\mysite\folder\index.cfm: How do I isolate the thing that it only gives me “folder” and NOTHING else? I tried getDirectoryFromPath, but I get an “all-or nothing- type result.
Please, someone put it up in idiot-code what do I need to do to just get the value of the current folder I’m in and nothing else.
Please don’t tell me use “x” function – I’ve tried a few but I’m at wit’s end!
Here are two possible ways:
<cfset dir = listLast(getDirectoryFromPath(getCurrentTemplatePath()),"/") />
<cfset dir = listGetAt(getCurrentTemplatePath(),listLen(getCurrentTemplatePath(),"/")-1,"/")/>
You may need to change the list delimiter to "\" depending on your platform.
--Nathan
Copy link to clipboard
Copied
Here are two possible ways:
<cfset dir = listLast(getDirectoryFromPath(getCurrentTemplatePath()),"/") />
<cfset dir = listGetAt(getCurrentTemplatePath(),listLen(getCurrentTemplatePath(),"/")-1,"/")/>
You may need to change the list delimiter to "\" depending on your platform.
--Nathan
Copy link to clipboard
Copied
<cfset dir = listLast(getDirectoryFromPath(getCurrentTemplatePath()),"/") />
- does not work, gives me the same ol' same ol'
<cfset dir = listGetAt(getCurrentTemplatePath(),listLen(getCurrentTemplatePath(),"/")-1,"/") />
Works a treat! This is what I was looking for - thank you, you are now the proud owner of a few beers next time you are in my hometown.
G