Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Defining #Application.RootPath#

Status
Not open for further replies.

calista

Programmer
Jan 24, 2001
545
US
This has been driving me nuts! X-) I have tried every way I can think of to define #Application.RootPath# in such a way that it always works. Here are me path definitions:
Code:
<!--- This is the root path for test --->
<CFSET APPLICATION.ROOTPATH=&quot;../../../CFDOCS/NewIntranet/&quot;>
<CFSET APPLICATION.COMMONPATH=&quot;#Application.RootPath#CommonFiles/&quot;>
<CFSET APPLICATION.IMAGEPATH=&quot;#Application.CommonPath#Images/&quot;> 
<CFSET APPLICATION.LOGOPATH=&quot;#Application.ImagePath#Logos/&quot;>
Here is a clip from a main page that works(image shows):
Code:
<TR>
			<TD><A HREF=&quot;Common/CommonIndex.cfm&quot;><IMG SRC=&quot;#Application.ImagePath#Common.gif&quot; WIDTH=&quot;120&quot; HEIGHT=&quot;41&quot; BORDER=&quot;0&quot; ALT=&quot;&quot;></A></TD>
		</TR>
If I click on this link to go down to the next level, the image doesn't show. Here it is on the next page:
Code:
<TR>
			<TD><IMG SRC=&quot;#Application.ImagePath#Common.gif&quot; WIDTH=&quot;120&quot; HEIGHT=&quot;41&quot; BORDER=&quot;0&quot; ALT=&quot;&quot;></TD>
			<TD><SPAN CLASS=&quot;ExtraLarge&quot;>Product Information</SPAN></TD>
		</TR>
If I change &quot;#Application.ImagePath#&quot; to &quot;../#Application.ImagePath#&quot;, it works. Yes, my images are within CFOUTPUT tags. Using #Application.RootPath# in my links doesn't work, either, once you go below the first level.

Isn't there some way to define these paths in such a way that they will always work no matter how many levels you have? What do the rest of you do? Calista :-X
Jedi Knight,
Champion of the Force
 
calista,
if you specify full path instead of relative path for
variable application.rootpath, the it works from any directory.

<cfset application.rootpath = &quot;or
<cfset application.rootpath = &quot;D:\test\test....>
 
Why go to the touble of using an Application level variable?

Presumably if you are running an application you have an Application.cfm file that is included into each and every page so you can set simple page level variables
<cfset imagepath=&quot;D:\test\test\&quot;> for example.

I suspect that this will have less overhead, it will be easier to type and will be more robust if you ever require to run on clustered servers.

 
Thanks, ram123, that seems to have done the trick! I thought I had tried that before, and it messed up if you clicked on a link to the same page you were already on. Anyway, it seems OK, now.

Thrud, thanks for your advice. As this is a small, company intranet I am building, clustered servers don't seem too likely in the foreseeable future. I see your point, and I will keep that in mind if I do need to operate on multiple servers. Calista :-X
Jedi Knight,
Champion of the Force
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top