Include a file

Discussion in 'HTML' started by Tony Wainwright, Feb 22, 2006.

  1. 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
    Tony Wainwright, Feb 22, 2006
    #1
    1. Advertising

  2. Tony Wainwright

    Dylan Parry Guest

    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?

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

    Listening to: Brahms - Symphony No. 2 in D major, op
    Dylan Parry, Feb 22, 2006
    #2
    1. Advertising

  3. No particular reason why, I just wondered
    Tony
    "Dylan Parry" <> wrote in message
    news:18xryynaisa7y$...
    > 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?
    >
    > --
    > Dylan Parry
    > http://webpageworkshop.co.uk -- FREE Web tutorials and references
    >
    > Listening to: Brahms - Symphony No. 2 in D major, op
    Tony Wainwright, Feb 22, 2006
    #3
  4. Tony Wainwright

    Dylan Parry Guest

    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.

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

    Listening to: Brahms - Symphony No. 2 in D major, op. 73
    Dylan Parry, Feb 22, 2006
    #4
  5. Tony Wainwright

    David Segall Guest

    "Tony Wainwright" <> wrote:

    >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.
    David Segall, Feb 22, 2006
    #5
  6. Tony Wainwright

    Stan McCann Guest

    "Tony Wainwright" <> wrote in
    news:dtheqd$gq1$-infra.bt.com:

    > 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.

    --
    Stan McCann, "Uncle Pirate" http://stanmccann.us/
    Webmaster, NMSU at Alamogordo http://alamo.nmsu.edu/
    Now blocking Google Grouper posts and replies.
    http://blinkynet.net/comp/uip5.html
    Stan McCann, Feb 22, 2006
    #6
  7. Tony Wainwright

    Tha RagMan Guest

    On Wed, 22 Feb 2006 10:35:58 +0000 (UTC), "Tony Wainwright"
    <> wrote:

    >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
    Tha RagMan, Feb 22, 2006
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Victor Bazarov

    #include "file" -vs- #include <file>

    Victor Bazarov, Mar 5, 2005, in forum: C++
    Replies:
    4
    Views:
    523
    Exits Funnel
    Mar 6, 2005
  2. PTM
    Replies:
    1
    Views:
    317
    Andy Dingley
    Nov 12, 2007
  3. naveeddil
    Replies:
    0
    Views:
    550
    naveeddil
    Jan 4, 2008
  4. Andreas Bogenberger
    Replies:
    3
    Views:
    880
    Andreas Bogenberger
    Feb 22, 2008
  5. Eric
    Replies:
    10
    Views:
    446
Loading...

Share This Page