Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"calling" HTML tables from one source to many html pages

Status
Not open for further replies.

RexDart

Programmer
May 22, 2002
8
US
I'm currently working with on a site that has a lot of pages. Included on every html page, are 3 navigation areas (basically, 3 html tables with hyperlinked text navigation). Since this navigation is replicated throughout the entire site, I would like to stip the nav out, and have it in a separate file that is "called" by every html page, so if I need to make a change, I only have to change the "nav" page, and the results are replicated throuhout the site, instead of manually changing the nav on every page. My question is, what's the best (aka easiest) way to do this? My site is hosted on a unix server... I believe that this cannot be done in CSS, because that is only for site appearance/formatting settings....correct?
 
Hi mate,

The best way to do this is to use SSI (Server Side Includes)

To use SSI, you would have to rename all of your pages to .shtml or whatever your server parses for SSI. Check this with your host.

After you rename the files, remove the text for the navbar ect, and put them in seperate html files.

Let's say that the navbar is in a file called navbar.html in the root directory, you now enter the following code on the .shtml page where you want the navbar to appear.

<!--#include file=&quot;/navbar.html&quot; -->

Do the same for all the rest of the pages and now when you want to update, you only update the one file.

If you use SSI, then the files will only be included when they are called through a web server. So if you tried to view the page on your local machine then the navbar would not be included.

Hope this helps Wullie

 
sounds good...i'll have to check with my hosting service to verify that SSI is an option they provide...How's the compatability of SSI with older browsers? Most of my website's target audience is &quot;stay at home moms&quot;, and most of them are on dial-up, using older versions of IE and netscape...After I posted this ?, I learned about iframes, and have begun testing that. So far, it works with both current versions IE & Netscape, and it also works with IE 5.X...
 
Hi mate,

SSI is processed server side before the page is sent to the browser so browser compatibitity is not an issue.

If you decide to use frames, you are bringing a whole new dimension of possible problems into the situation. Frames are not search engine freindly..

I have to say though that I hate frames so you are always going to get a reply like that from me about them.. [wink]

Hope this helps Wullie

 
ok...thanks for your advice...i've started using SSI to separate the nav elements from the site. So far, it's working great, but I do have one ?.... here's my dir structure...main html files in root directory; nav pages called by SSI located in a folder called nav. So, when I call for SSI in the html, my call looks like this:

<!--#include file=&quot;nav/left-nav.html&quot; -->

this works perfectly for any html file that's in the root dir. However, I also have html files in a sub directory in the root. when I try to call the nav html files, it gives me an error. I've tried the following ways:

<!--#include file=&quot;../nav/left-nav.html&quot; -->
<!--#include file=&quot;nav/left-nav.html&quot; -->
<!--#include file=&quot; -->

none of these have worked. I cannot get SSI working when the html page isn't in the root dir... what do I need to do?
 
Hi mate,

Just use the path from the root directory..

<!--#include file=&quot;/nav/left-nav.html&quot; -->

The reason the URL doesn't work is that you can only call files directly through the server path and not a url. This is for security reasons so that someone can't just put in something like the following..

<!--#include file=&quot; -->

If that worked then they have the password file for your system..

Hope this helps Wullie

 
Ok...here's a pic of my directory structure...

dir.gif


I've tried the following combinations of SSI calls to get the data displayed on the shtml pages in the subdirectorys, without any luck:

<!--#include file=&quot;nav/top-nav.html&quot; -->
<!--#include file=&quot;/nav/top-nav.html&quot; -->
<!--#include file=&quot;../nav/top-nav.html&quot; -->
<!--#include file=&quot;top-nav.html&quot; -->

for example, say i'm trying to use SSI in the local directory... there's a page called mooresville.shtml in the local dir. I'm trying to call top-nav.html from the nav dir, using SSI...I tried all the above combinations, and all returned the msg:

&quot;[an error occurred while processing this directive]&quot;

The only way i've gotten a shtml to correctly display the SSI-inserted code is to put the top-nav.html file in the same dir, and then use

<!--#include file=&quot;top-nav.html&quot; -->

That's obviously not a solution, because I'd have to put those files in every sub-dir, and that defeats the purpose of using SSI....any suggestions on to why this isn't working? I was on the phone for about 30mins earlier 2day with my hosting company's tech support, and they too couldn't figure out why this wasn't working...
 
nope, didn't work...

here's the result...



I'm in the process of re-doing the entire site, using more graphics, etc....and while I'm updating the site, I'd like to be able to use SSI to make my job easier...I havn't heard back from tech support on this issue...I'll keep u updated...thanks
 
I got it working!....

<!--#include virtual=&quot;/nav/top-nav.html&quot; -->

all I had to do was change it to this...

<!--#include virtual=&quot;../nav/top-nav.html&quot; -->

it now works fine....thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top