How to set a variable based on a user selected folder / directory location of .cfm file
Posted on 2007-03-27
Hello CF Experts,
I have a CF application that I would like to dynamically set an ID variable based on the folder location of the .cfm file.
So, in my application, I have folders named Category1, Category2, Category3 and so on.
In those folders, I have index.cfm.
I would like to set a (known) category ID based on the folder (category) that the user chooses.
The logic would go something like this.
If folder name Category1 is detected in URL, set this:
<cfif (detect folder name for Category1 in url)>
<cfset sectionID = "123456">
<cfif (detect folder name for Category2 in url)>
<cfset sectionID = "123457">
Again, we already know what the ID is going to be, which will corelate to the chosen category, we just need to have a way to detect the folder name on the site that they choose. Of course, we could always hard code the categoryID in the URL on the category selection page, but we don't really want to do that here. Our main page is not dynamic in nature, and we are fine with that.
Thanks in advance for any help!