by George Hawkins » Thu May 20, 2004 7:03 pm
Most coding is done in the manner that Baggs suggeseted but their is another alternative witch works the same way. HTML includes!
They are written almost the same and I use them frequently because I write code in HTML, DHTML, JAVASCRIPT and ASP. I actually learned this trick from ASP.
PHP is great but for someone that doesn't know that language it is nearly impossible for you to do it with minimal experience with complex coding.
Ready for this!
Example:
Normally you have one file with a select portion of your code that is repetitive, as your navigation. To make it global you want to cut it out from the code and place it in a new HTML file.
Cut it from <Table> to </Table> then what I do is add a comment tag in front of the the <Table> tag to let me know where it was and where it ends.
Once you have this in a new doc strip the page of all other attributes, such as title, body all that.! seriously all of it. Save as nav.html.
Then go back to your original page where you snipped it out and place this in their where the nav use to be.
*************************************************
<!-- Open Navigation -->
<!--#include virtual="includes/nav.html"-->
<!-- Close Navigation -->
**************************************************
This is a comment tag> "<!-- Open Navigation -->" the browser will not render to be seen in the page... it is kind of like an invisible post-it note.
This is an Include tag> "<!--#include virtual="nav.html"-->" this is the file that references the other file that you made that grabs the code that you want to place in the original area that it was in.
This is the closing comment tag > <!-- Close Navigation --> this just tells you where the nav files code ends just good to have a start and end. : )
I personally place a new file folder in my directory so that all my includes are together nice and neat. but you will need to restructure your file directory basically call it to a new folder such as this:
"<!--#include virtual="includes/nav.html"-->" see the "includes/" that tells it to look deeper in a different folder than in the main directory and find the nav file or other includes that you place in there such as headers, footers, nav, etc. etc.
then you are done it is basically a very easy process.
front to back here is a full example:
About us Page:
<body>
<table>
<tr>
<td>
<!--#include virtual="nav.html"-->
</td>
</tr>
</table>
</body>
nav.html Page:
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td>link 1</td>
<td>link 2</td>
<td>link 3</td>
<td>link 4</td>
</tr>
</table>
that is it... Just make sure on that you talk to the people that handle your hosting that they need to turn on Serverside Includes for your directories....... Tell them that you are using HTML includes "not ASP includes" which work almost identically the same... and you shouldn't have a problem.
Remember you will not be able to see this work until it is hosted on the web... you will not be able to see this working from the desktop. Unless you have like Dreamweaver, they have testing environments that will allow you to see it as you work.. that is how I see them locally but you will probably need to work with these two file examples over the web and it should be no propblem once you have the hosting turn on the "configuration".
Good luck
Any questions? I'll check back to see if it worked for you! hope that made sense... lol