Page 1 of 1

help: html include

Posted: Fri Aug 19, 2005 5:29 am
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>

ASP includes

Posted: Fri Aug 19, 2005 7:11 am
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

Posted: Fri Aug 19, 2005 7:43 am
by timvw
I believe it's called SSI (Servide Side Includes) and apache can be configured to do this...

So is it just a web server config issue?

Posted: Fri Aug 19, 2005 8:01 am
by AnarKy
So is it just a web server config issue?

Posted: Fri Aug 19, 2005 8:14 am
by feyd
yep, SSI.

Posted: Fri Aug 19, 2005 10:37 am
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. :)

Posted: Fri Aug 19, 2005 4:19 pm
by feyd
why not make them scripts?

Posted: Sat Aug 20, 2005 5:04 am
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:

Posted: Sat Aug 20, 2005 8:30 am
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>

Posted: Sat Aug 20, 2005 10:09 am
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 :)