Include a file

T

Tony Wainwright

Hi
I am teaching myself how to develop websites for my own benefit and have
come across something that I don't know how to do. I want to be able to
include in every page a file that contains information that will be
displayed on every page i.e. copyright info. I don't want to have to
re-write every page when I change this information - I just want to be able
to edit it once. I know it can be done in PHP (as shown below), but I want
to be able to do it in HTML.
<?php
include_once ('includes/copyright.html');
?>
Is this possible?

Thanks
Tony
 
D

Dylan Parry

Pondering the eternal question of "Hobnobs or Rich Tea?", Tony
Wainwright finally proclaimed:
I know it can be done in PHP (as shown below), but I want
to be able to do it in HTML.
<?php
include_once ('includes/copyright.html');
?>
Is this possible?

In HTML alone, not really. You could use inline frames, but that would
be a particularly bad idea. Is there any particular reason why you
/can't/ use PHP for this?
 
T

Tony Wainwright

No particular reason why, I just wondered
Tony
Dylan Parry said:
Pondering the eternal question of "Hobnobs or Rich Tea?", Tony
Wainwright finally proclaimed:


In HTML alone, not really. You could use inline frames, but that would
be a particularly bad idea. Is there any particular reason why you
/can't/ use PHP for this?

--
Dylan Parry
http://webpageworkshop.co.uk -- FREE Web tutorials and references

Listening to: Brahms - Symphony No. 2 in D major, op
 
D

Dylan Parry

Pondering the eternal question of "Hobnobs or Rich Tea?", Tony
Wainwright finally proclaimed:
No particular reason why, I just wondered

Please don't top-post :)

Well if the reason was just wondering, then that's okay! Really the best
way to attempt to include a file is on the server-side rather than
relying on the client's machine to do the work. I'd stick to using PHP
for it as it's much more reliable.
 
D

David Segall

Tony Wainwright said:
Hi
I am teaching myself how to develop websites for my own benefit and have
come across something that I don't know how to do. I want to be able to
include in every page a file that contains information that will be
displayed on every page i.e. copyright info. I don't want to have to
re-write every page when I change this information - I just want to be able
to edit it once. I know it can be done in PHP (as shown below), but I want
to be able to do it in HTML.
<?php
include_once ('includes/copyright.html');
?>
Is this possible?
I don't think so but you may want to consider a preprocessor that
expands the includes and other macros before you upload the HTML. A
Google for HTML preprocessor yields many of them.
 
S

Stan McCann

Hi
I am teaching myself how to develop websites for my own benefit and
have come across something that I don't know how to do. I want to
be able to include in every page a file that contains information
that will be displayed on every page i.e. copyright info. I don't
want to have to re-write every page when I change this information -
I just want to be able to edit it once. I know it can be done in PHP
(as shown below), but I want to be able to do it in HTML.
<?php
include_once ('includes/copyright.html');
?>
Is this possible?

If your sever supports SSI, then:
<!--#include virtual="includes/copyright.html" -->

If you are going to try instead of ask, some installations use the
Xbithack which requires the file including others to have the x bit
set.
 
T

Tha RagMan

Hi
I am teaching myself how to develop websites for my own benefit and have
come across something that I don't know how to do. I want to be able to
include in every page a file that contains information that will be
displayed on every page i.e. copyright info. I don't want to have to
re-write every page when I change this information - I just want to be able
to edit it once. I know it can be done in PHP (as shown below), but I want
to be able to do it in HTML.
<?php

Have you considered SSI ? Take a look at this site for info on how:
http://www.smartwebby.com/web_site_design/server_side_includes.asp
Best of luck.
Tha RagMan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top