help: html include

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

help: html include

Post by raghavan20 »

I was thinking of creating separate files for header, menu and footer and including these files in all other files in the website.

so I basically try to include few html files in another html file
syntax I got:
<!--#include file="somefile.ext"-->
I have got all the including files in the same directory where the target file is.
Now, it does not include rather this is wot it does.

this is wot it printed when I viewed the source of the target file

Code: Select all

<!--#include file="header.inc"-->[b]//you see this is intact[/b]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Weather</title>
</head>
<body>
</body>
</html>
User avatar
AnarKy
Forum Contributor
Posts: 119
Joined: Tue Nov 02, 2004 1:49 am
Location: South Africa

ASP includes

Post by AnarKy »

Hi,
I think that those includes only work in ASP?!

Are you running ASP?

You can use the php server side includes:
http://www.php.net/manual/en/function.include.php
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

I believe it's called SSI (Servide Side Includes) and apache can be configured to do this...
User avatar
AnarKy
Forum Contributor
Posts: 119
Joined: Tue Nov 02, 2004 1:49 am
Location: South Africa

So is it just a web server config issue?

Post by AnarKy »

So is it just a web server config issue?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

yep, SSI.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

I jus pulled this include from somewhere. I have used this kind of thing in asp but I need help to include html files.
hope you guys can give me the syntax. :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

why not make them scripts?
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

do you suggest me to do php scripts for all html includes??? :roll:
I can do that but why is not there a html include :cry:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's not like making it a script would be any different...
  • tell the server to process HTML as PHP
  • Code: Select all

    <?php
    // do any pre-processing
    ?>
    <html>
    <body>
    <?php include 'header.html'; ?>
    <!-- some stuff -->
    <?php include 'footer.html'; ?>
    </body>
    </html>
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

I hv done it in a different way.
I created a htmlIncludes.php file and created functions to echo header, menus and footer
and i include this in all other files and call these functions where necessary.
thanks for your help, feyd :)
Post Reply