Click to See Complete Forum and Search --> : Including external HTML files...?


MadCatter101
08-31-2003, 04:16 PM
Ok. I am incredibly confused. I'm trying to lay out a website using CSS and HTML, and hopefully nothing more. My problem, however, is thus:

I want to have one file (template.html) that will contain the basic layout for my page--nav bars, headers, everything but content, basically. I have the page set up already. What I'm looking for now, is a way to take that HTML file and include it in a content page (e.g. to have content.html load the info out of template.html), so that whenever I update the layout of my site, all I would have to update template.html(rather than updating every page on my site). Is there any way to do this WITHOUT using Java, jscript, PHP, or what-not? I've been looking for a difinitive answer but havent been able to find one... help?

thanks a bundle.

MadCatter101

David Harrison
08-31-2003, 04:23 PM
What I've done with the site I'm currently designing is to put everything in div tags and include no styles whatsoever in the body of the page, then I have attached a .css file layout.css which arranges the content on the page and determines what size font to use, backgroung pictures etc. That way I only have to update 1 file.

You can attach .css files like so:

<style type="text/css" src="file.css"></style>

The page I'm currently designing is here (http://www.websamba.com/testorg/).

MadCatter101
08-31-2003, 04:29 PM
I know what you mean, and I'm doing the same thing... BUT! What I want to do is, have one HTML file that has all but one of the <div> tags included in it (e.g. <div id=navbar>, <div id=adbar>, etc.), and include that HTML file *inside* a second HTML file, which would look something like this...

<BODY>
<whatever code to insert template.html>
<div id="content">
My main content for this page
</div>
</BODY>

So that all I have is the one div tag in my content page. All I need is the code to insert the other HTML page...

...if it exists....

David Harrison
08-31-2003, 04:34 PM
It sounds like what you need is an iframe:

<body>

<div id="adbar">Blah Blah Blah</div>

<div id="navbar">Blah Blah Blah</div>

<div id="mainpage">

<iframe src="http://www.w3.org/" name="main" width="100%" height="100%">You can't view iframes</iframe>

</div>

</body>

Then just target your links to the iframe.

MadCatter101
08-31-2003, 05:24 PM
Thanks! I hadnt considered iframes.

What I wound up using was something like this...

<div id="navbar">
<iframe src="navbar.html"> (with attributes, obviously) </iframe>
</div>

etc. etc. for other frames.

This'll have to be c+ped into everything, but... oh well... its better than doing a frickin table every time I want to make a new page.

Thanks, lava!

David Harrison
08-31-2003, 05:25 PM
Happy to help. :)

MadCatter101
08-31-2003, 08:43 PM
Ooh. Someone on another forum gave me an even better way to do it:

<!--#include file="template.shtml"-->

Simple server-side include.

As long as the server supports server-side includes... hehehe.

It's the closest method to what I wanted to do, since iframes are (in my opinion), more complicated to use than CSS layout. Of course, I could be crazy... but this works just as well.

PeOfEo
08-31-2003, 08:46 PM
Well iframes with a css layout can be buggy on ie with relative positioning especially, I aggree with you there.

David Harrison
09-01-2003, 11:45 AM
I didn't even realise that you could do that. You'd have to be careful to delete all of the <html><head> etc. otherwise you'd have very messed up code.