Log in

View Full Version : HTML Trick


Raptisoft
01-09-2004, 02:37 PM
Hi all,

I'm looking for a little info on HTML coding. Google search reveals nothing-- obviously I'm using the wrong words.

What I'm essentially trying to do (using Dreamweave MX to edit) is have a couple HTML pages that get "included" into a page that's opening. The reason is, I want to have several similar looking web pages that just go ahead and grab the header and footer html pages from elsewhere on my site. For example, I'd have a table, and cell #1 would grab header.html and display it, cell #2 would be my custom stuff for the page, and cell #3 would grab footer.html and display it.

Is there a way to do this? It seems that the only alternative would be to use frames, which I want to steer away from.

Thanks!

Matthew
01-09-2004, 03:05 PM
It's easy to do with a server-side language such as PHP (http://www.php.net). Chances are your host supports PHP; it's practically ubiquitous these days. The PHP processor runs commands embedded in special tags. You can actually rename an HTML file to PHP and it'll behave the same way, since it doesn't have any PHP tags. For your situation, you'd create something like header.php and footer.php (could be pure HTML)

Your content.php page would read something like:


<?php
include("header.php");
?>

Your HTML-formatted content here.

<?php
include("footer.php");
?>


It sounds like it's probably overkill for your situation, but Smarty (http://smarty.php.net/) is a very powerful templating system written in PHP. If your host doesn't support PHP, btw, you could do similiar to above with server-side includes (.SHTML pages) like:


<!--#include virtual="/header.html" -->

Your HTML-formatted content here.

<!--#include virtual="/footer.html" -->

triptych
01-09-2004, 03:27 PM
You might also try using XSL-T to construct the header and footer - then the files could be placed somewhere else and reused.

Larry Hastings
01-09-2004, 03:40 PM
The terminology you want is called "server-side include". You can do it with something heavyweight like PHP, but your web server should do it automatically.

It looks like www.raptisoft.com is served by IIS. In which case, may I direct you to Using Server-Side Include Directives (http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/windowsserver2003/proddocs/standard/pub_svrsideincludes.asp) from MSDN.

By the way, as impressive as Hamsterball is, I'm still looking for "Ferreting". My sister keeps ferrets, and she was intrigued by the name. When we gonna see it?

Raptisoft
01-09-2004, 03:43 PM
Thanks for the replies, everyone. I'll give a few of these a try, see what works best fo' me.

As for Ferreting... it's more or less the Popcap game "Candy Train" re-themed. In Ferreting, you rotated bits of a rabbit warren to steer your ferret to chase all the rabbits out the top. Sort of bloodthirsty.

formfarbeminze
01-10-2004, 04:54 AM
you may wish to read this article

http://tech.irt.org/articles/js087/

which deals with "embedding html files".

damocles
01-18-2004, 05:25 AM
I may have misunderstood your request - but wouldn't iFrames do the trick? Look them up in dreamweaver's html referece. You can "insert" other pages into table cells using iframes. Dead easy to use too.