?
Solved

CFINCLUDE and the magic table

Posted on 1999-12-04
6
Medium Priority
?
258 Views
Last Modified: 2013-12-24
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.
0
Comment
Question by:beregoth
6 Comments
 
LVL 1

Expert Comment

by:rod_nolan
ID: 2255285
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
0
 

Accepted Solution

by:
netdisciple earned 300 total points
ID: 2261181
ok, rod points out some obvious things that needed mention, like the filenaming prob, but what he failed to specify at the end was that the cfinclude tag explicitly adds the contents of the nav2.cfm file to the container file...meaning, you only write the code you really need into nav2.cfm. so get rid of the <HTML> and <BODY> declarations and only include code for the tables or  table cells you need to include in....

check <code> below


Example 1: container file
---

<html>
<body>
<table>
<cfinclude url="include_snip.txt">
</table>
</html>


Example 2: include_snip.txt
---


<tr><td>menu item 1</td></tr>
<tr><td>menu item 2</td></tr>
<tr><td>menu item 3</td></tr>

0
 

Expert Comment

by:netdisciple
ID: 2261191
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.
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
LVL 5

Expert Comment

by:nathans
ID: 2281487

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>


0
 
LVL 1

Author Comment

by:beregoth
ID: 2281520
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.
0
 
LVL 1

Author Comment

by:beregoth
ID: 2281524
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.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
This installment of Make It Better gives Media Temple customers the latest news, plugins, and tutorials to make their Grid shared hosting experience that much smoother.
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question