Better way to set Dynamic Directory References?
I have several projects set up in the following directory structure:
\ (contains index.cfm and application.cfc)
\cfc (contains all CFCs)
\html (contains all non home page files)
\images
\includes
\config
(and so on)....
The application.cfc uses REQUEST variables to reference the page location to link to based on where the location is. This is not very good practice, but is an ancient holdover from CF5 when I first started in Coldfusion.
Here is an example:
<!--- if page location anywhere but root--->
<cfif findnocase('html/',cgi.script_name) gt 0 or
findnocase('includes/', cgi.script_name) >
<cfset request.includes='../includes/'>
<cfset request.html="../html/">
<!---(... and so on )--->
<cfelse>
<cfset request.includes='includes/'>
<cfset request.html="html/">
<!---(... and so on )--->
</cfif>
Then I use the reference:
<a href='#request.html#page.cfm'>NavLink1</a>
There has got to be a better way to skin this animal. While I am plowing through beans and configs, in the meantime I have several projects that I just want to perform some simple cleanup on.
Anyone got any better suggestions? The settings would need to change based on a page by page basis but aren't updated or reset by the user .
A

<cfsavecontent variable="content">
<cfinclude template="/includes/Header.cfm">
<cfinclude template="#targetPage#">
<cfinclude template="/includes/footer.cfm">
<cfabort>
</cfsavecontent>
<cfoutput>
#content#
</cfoutput>
Place the code in your application.cfc/cfm and modify directories as needed and you are ready to rock...
Also not the prettiest solution though it works
Thanks, and I have used this approache before, but it doesn't allow me to dynamically determine a relative path based on the current file's location. I want to keep that functionality, but use something more elegant than so many request variables for directory structure.
href="/includes/whatever/page.cfm"