Link to home
Start Free TrialLog in
Avatar of beregoth
beregoth

asked on

CFINCLUDE and the magic table

Now, I have done this in ASP and I don't believe that I have had the same problems though it has been a while so bear with me.  So I have a simple master page like this...

<html>
<head>
<title>mjSoftware</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body topmargin="0" leftmargin="0">
<table width = "100%" height = "100%" >
  <tr height="50" bgcolor="#7ab3c0">
    <td colspan="3" height="50" valign="middle" border="2" bordercolor="#000000" >hello </td>
  </tr>
  <tr height="100%">
    <td width="110" bgcolor="#7ab3c0"></td>
    <td width="0"> </td>
    <td width="110" align="right" valign="top"><cfinclude template="nav2.htm"></td>
  </tr>
</table>
</body>
</html>

and the include is like this...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
      <title>Untitled</title>
</head>

<body topmargin="0" leftmargin="0" bgcolor="#7AB3C0">
<img src="Images/Navigation/nav1.gif" width="110" height="25" alt="" border="0" align="right"><br><br>
<img src="Images/Rules/blackspacer.gif" width="110" height="2" alt="" border="0" align="right"><br>
<img src="Images/Navigation/nav2.gif" width="110" height="25" alt="" border="0" align="right">
</body>
</html>

...and no matter what I do, the right-most table column displays nothing but of course the nav2.cfm file will display properly by itself just fine.  I am sure there is some simple trick to how to use CFINCLUDE effectively that I am missing but having not used it before and really wanting to use this technique, I would love some guidance.
Avatar of rod_nolan
rod_nolan

Before I make any assumptions, I'll point out an obvious possibility. You call the file nav2.CFM in your explanation but in your master page code, it's nav2.HTM. So first, check to make sure that it's not something simple, like a mistyped filename. If that was the case though, you'd get the 404 Object Not Found error... and you would have posted that information along with your explanation, right? ;)
The reason I brought that up is because the error wouldn't have been visible at first glance in the browser or CF Studio's internal browser because you've set the table height to 100%.

If that's not the problem, read on...

You say that the rightmost table column in the master page displays nothing. Does that mean that there's literally nothing in the table cell or do you get broken images?

Just a tip for troubleshooting table problems: set the table border to 1 so you can see the cell boundaries and always view the source of the html page that CF produces to see if it does what you expected it to do. That'll help you determine whether the problem is with your CF code or your HTML code.

<CFINCLUDE> is just like a programmatic copy-paste. It simply inserts the contents of the included file into the calling file at run time. So the code in the included page assumes the directory of that calling page. If those pages are in different directories you'll get relative path resolution problems for your images and hyperlinks.

That's what it sounds like to me because you say that the nav page works ok on it's own but doesn't work when included in the master page.

Good Luck,
Rod
ASKER CERTIFIED SOLUTION
Avatar of netdisciple
netdisciple

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you see, the included file doesnt even need to be a .cfm file.

anyhow...all you need to have is the container file named with a .cfm filename extention so the webserver knows to run it through CF. Essentially, <CFINCLUDE> is the allaire alternative to Server-Side Includes which tend to be very expensive in CPU cycles.  Not sure if CF helps this statistic any, but its a rather useful tag in my opinion.

It worked on my machine?

What browser are you useing?
I got two broken links for the two images.  I didn't get a broken link for the Spacer.  I added test to the top and bottom just to see what would happen.  
What resolution are you using?


<html>
<head>
<title>mjSoftware</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body topmargin="0" leftmargin="0">
<table width = "100%" height = "100%" > 
  <tr height="50" bgcolor="#7ab3c0">
    <td colspan="3" height="50" valign="middle" border="2" bordercolor="#000000" >hello </td>
  </tr>
  <tr height="100%">
    <td width="110" bgcolor="#7ab3c0"></td>
    <td width="0"> </td>
    <td width="110" align="right" valign="top"><cfinclude template="nav2.htm"></td>
  </tr>
</table>
</body>
</html>





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>

<body topmargin="0" leftmargin="0" bgcolor="#7AB3C0">
test
<img src="Images/Navigation/nav1.gif" width="110" height="25" alt="" border="0" align="right"><br><br>
<img src="Images/Rules/blackspacer.gif" width="110" height="2" alt="" border="0" align="right"><br>
<img src="Images/Navigation/nav2.gif" width="110" height="25" alt="" border="0" align="right">
test
</body>
</html>


Avatar of beregoth

ASKER

Sorry nathans but I am not sure what question you are answering.  The problem is not the content of the include file (ultimately I have found that it is though), specifically the graphics, it was the raw html content...the <HTML> and <BODY> tags were included and causing grief.
This was the clue I was looking for and it was really obvious once I looked at it.  Thanks to everyone for the commentary and assistance.