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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFInclude problem!

Status
Not open for further replies.

esfinks

Programmer
Feb 28, 2001
7
AE
Hi there,
Suppose that I have the followin':
- a directory called 'mango/html/guestbook'.
- a file called 'mango/html/header.cfm'.
- a file called 'mango/html/guestbook/default.cfm'.
- the file 'mango/html/header.cfm' gets some images from the directory 'mango/images' (Important).

So how can i include the 'mango/html/header.cfm' within 'mango/html/guestbook/default.cfm'.

I tried the followin' inside 'mango/html/guestbook/header.cfm' file:
<cfinclude template=&quot;../header.cfm&quot;>
and I tried the followin' also:
<cfinclude template=&quot;mango/html/header.cfm&quot;>
but all of that didn't work!

Please keep in mind that 'header.cfm' gets images from 'mango/html/images'.

When I tried <cfinclude template=&quot;../header.cfm&quot;> I got an error sayin' that the template can't be found!
When I tried <cfinclude template=&quot;mango/html/header.cfm&quot;> I got no error, but I couldn't see any of the images on the header!

Would you help <esfinkis> pls :) <esfinkis></esfinkis>
 
I've had the same problem, and I have a couple of suggestions.

First,(and please forgive me if I am insulting your intelligence, but I made this mistake) make sure your images are within <cfoutput> tags.

Second, I set up application variables with the fully qualified path name to point to the folder where my images are.

Here are the application variables:

Code:
<CFSET application.RootPath=&quot;/cfdocs/TLGD_Intranet/&quot;>
<CFSET application.ImagePath=&quot;#Application.RootPath#Images/&quot;>

And here is how I reference them in my header page:

Code:
<!--- This is the beginning of the Page Header --->
<cfoutput>
<h1><b><font face=&quot;Times New Roman&quot;><div align=&quot;center&quot;>Inside Tollgrade</div></font></b></h1>
<h2><b><font face=&quot;Times New Roman&quot;><div align=&quot;center&quot;>#Subheading#</div></font></b></h2>
<img SRC=&quot;#Application.ImagePath#RainbowLine.gif&quot; width=&quot;100%&quot;>
</cfoutput>
<!--- This is the end of the page header. --->

Hope this helps! :-)
 
Hi Calista, Hi Everybody

The problem that ColdFusion CFInclude tag doesn't accept the physical path ...

Ok, I have the file c:/netscape/suitespot/docs/site1/header.cfm
And the files c:/netscape/suitespot/docs/site1/html/guestbook/default.cfm
c:/netscape/suitespot/docs/site1/html/media/default.cfm
c:/netscape/suitespot/docs/site1/html/news/default.cfm

All that i wanna do is to include the header.cfm file into the default.cfm pages of each subfolder.

how can i do that?!!!
<cfinclude template=&quot;../header.cfm&quot;> doesn't work
<cfinclude template=&quot;c:/netscape/suitespot/docs/site1/header.cfm&quot;> doesn't work also ..

And would you tell me what's the meaning of (../header.cfm)?

Thanx alot. <esfinkis></esfinkis>
 
Check this:

Specifying relative template path works fine for me.

Absolute paths are like the one I just supplied, it has a complete host address .. a relative path is like &quot;../header.cfm&quot;

the &quot;..&quot; means go UP one directory.

My 1.cfm includes ../footer.cfm from strantheman.com/ .

As far as the image issue, you have to make your image path absolute if you wish to access those images from anywhere in the site without customizing the location of the image every time. I suggest a variable in application.cfm called imgroot.

<CFSET imgroot=&quot;
Then your img tags would be:
<img src=&quot;#imgroot#/px.gif&quot;>

Also, do not include the final '/' in the variable, as you'll confuse yourself later using that variable, and you'll end up with a link or img src like or
Hope I could help. Ive dealt with so many relative path issues.. one time i made a dynamic relative path function in my application.cfm ... so no matter where I was the application always new how many levels deep I was and could always find those templates in my root.
 
I'm having the same trouble of relative cfinclude and cflocation paths not working. It's a very simple thing like[COLOR=003366]<cfinclude template=&quot;../qry_programs.cfm&quot;>[/color] or [COLOR=003366]<cflocation url=&quot;../index.cfm&quot;>[/color], and it's a complete no-go.

Any consistent reasoning for this? If it makes any difference in diagnosis, I'm using CF4.0.1 on IIS/NT4.

Increasingly peeved,
David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top