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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Components Question

Status
Not open for further replies.

kennyaidan

Programmer
Apr 9, 2003
54
0
0
IE
Hi,
I am currently designing a website and I was hoping to use components in my design. What I wanted to do is have my main section pages with the side navigations and headers files etc included as separate components so that when I make a change to the left nav for an example, I only have to make the change once and not for each individual page.

I was hoping that one of you guys might advise me on the best way to do this as I have tried doing it myself and it doesn't seem to work.

I just used the following code to include the components.
<&/header.htmlf&>

Is it dependent on the type of server I use or do I need to define a script language i.e.
<script language="JavaScript" type="text/javascript"></script>

This components the best way to deal with this problem?

Any help or advice greatly appreciated.

Thanks
Aidan
 
to some extent it does depend on your server.

for SSI (Server Side Include) the including file must be named with a .shtml extension
<!--#include file="header.html"-->
if the included file is in the same folder or in a folder below.
or
<!--#include virtual="/includes/header.html"-->
if the included file is referenced from the root or is in a folder above.

ASP is the same syntax but the file extension can be .asp as well.

PHP include syntax

<? include("/includes/header.html")?>

and the including file ext must be .php

for far more on SSI take a look at SSI Developer



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Thanks Chris for the help

I have tried what you suggested but it still isn't working, I am probably making some basic mistake so i have attached the code so you might be see the problem

#include file="header.html"

<HTML>
<HEAD>
<TITLE>ferna_website1</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/javascript"></script>

</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>

<&/header.html&>

</BODY>
</HTML>

Thanks again for the help

Aidan
 
not this
#include file="header.html"
or this
<&/header.html&>

but this

<!--#include file="header.html"-->

placed where the included file should appear. The apparent HTML comment tags are part of the syntax.

so

Code:
<body>
<!--#include file="header.html"-->


<!--    rest of code    -->

</body>
Using SSI will require the pages to be served from a SSI enabled server, simply opening them from your hard drive won't work.


Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Thanks Chris
Thats working fine just one last quick question. I have saved my file as index.shtml in order for the include to be picked up on. If i save it as index.html the include does not appear. Would this be correct and I so when my web page is opened will index.shtml appear automatically or will the the browser still look for index.html as the default home page?
i.e. Is the same as
thanks
aidan
 
kennyaidan said:
I have saved my file as index.shtml in order for the include to be picked up on. If i save it as index.html the include does not appear.

This is your server config. It's set to parse files ending .shtml through the SSI engine, but not .html.

kennyaidan said:
or will the the browser still look for index.html as the default home page?
The default page is also decided by the server - NOT the browser.

<marc> i wonder what will happen if i press this...[ul][li]please tell us if our suggestion has helped[/li][li]need some help? faq581-3339[/li][/ul]
 
Ok guys,
That seems to answer all my questions so thanks alot for the help much appreciated

aidan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top