Click to See Complete Forum and Search --> : Editing only one part of your website...?


fredish
10-29-2008, 04:39 PM
I'm currently creating a website, using frames, but there's something on the side bar that I will constantly be needing to update. How do I update this information, without having to edit every single page??

I've heard something about 'includes'.. I don't know whether that's relevant!

eCat
10-29-2008, 05:32 PM
If the side bar is one of your frames, you just update that frame. That's one reason that frames were popular... oh, so long ago...

fredish
10-30-2008, 04:28 AM
Sorry, I meant tables, not frames!

eCat
10-30-2008, 05:44 PM
Ah! Whew! :p

So yes, you could use an include. Create an html file and give it a useful name (like for navigation you might call it left_nav.htm). Then in your table cell, you'd put a reference to that document like this:

<!--#include file="left_nav.htm"-->

Then, you just update that one file, upload it to your server and tah dah! Your pages are all up-to-date because they call to that file when the page is loaded.

PS: I don't think I've ever used an include inside of a table before, so you may have to fiddle around with height & width a bit before it works the way you want it to.

PPS: if this doesn't work, it may be because your server doesn't support this type of include. There are many other types - PHP, Javascript, etc. Just do a google search for "html includes."

eCat

Shorts
10-30-2008, 05:53 PM
If you are using:


<!--#include file="left_nav.htm"-->


Make sure SSI is available on your server and you might need to use the extension .shtml (unless you use .htaccess or equivalent).

In PHP it would be similiar:


<?php include("left_nav.htm"); ?>


In that case you would use the file extension .php (or again, .htaccess).

However both of those require Server Side Scripting (which most hosts do support). If not, you can set it up by using JavaScript.


<script src="left_nav.js" type="text/javascript"></script>
<script type="text/javascript">
document.write(left_nav());
</script>


and then in left_nav.js:


function left_nav() {
var left_menu = '<li><a href="link.htm">link</a></li>';
left_menu += '<li><a href="another_link.htm">another_link</a></li>';
left_menu += '<li><a href="etc.htm">etc</a></li>';
return left_menu;
}


This last idea should only be used if you have no other way. Dynamically on the server side is preferred (PHP, ASP, JSP, SSI, etc).

fredish
10-31-2008, 04:11 AM
Thanks so much, it's working great in the table! :D