How do I "import" a html file throughout my site?

Discussion in 'HTML & Website Design' started by Diminished29, Sep 27, 2007.

  1. #1
    I have a "recent updates" page and I only want to have to update it once instead of copying it over throughout all the pages on my site. For right now it hasn't been too bad as I don't have that many pages, however, the site is only a little over a month old and will only be getting bigger. So I need a solution for this fast.

    I run off of a windows server from 1&1, so I'm assuming this will need an ASP or PHP script.

    Any help is appreciated.
     
    Diminished29, Sep 27, 2007 IP
  2. Diminished29

    Diminished29 Peon

    Messages:
    81
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Alright cool stuff, I believe I got it. Only thing that sucks now is I'm using Notepad ++ which has different colors for the tags and what not and is VERY handy as I'm sure most of you guys already know.

    Problem now is that Notepad ++ only seems to recognize these as being text files and not html files since it now has a ".shtml" extention. In turn not only can I not view it on my home computer before I put it on the server but the tags are no longer colored in Notepad ++, which makes it no better than Notepad save for built in tag option it in which it has for each page.

    Here is the files I used:

    uksurveys.shtml and recentupdates.shtml

    and then put in the SSI script on the uksurveys.shtml page like so:

    <!--#include virtual="recentupdates.shtml" -->

    UPDATE

    Alright, I went ahead and tried something I've seen on a lot of other pages, instead of using the ".shtml" file extention I used a ".php" well...that didn't work.

    So I then used an ".asp" extention...and BINGO...I got it! I also got my colors back in Notepad ++ I'm a happy camper now!
     
    Diminished29, Sep 27, 2007 IP
  3. longhornfreak

    longhornfreak Well-Known Member

    Messages:
    2,067
    Likes Received:
    95
    Best Answers:
    0
    Trophy Points:
    140
    #3
    you only need to upload one file and overight the existing one. So if you make an update to index.html, don't upload your whole site, just upload the new index.html

    If your index page is really big and it takes a while, you can use PHP to make a config file for certain things on your index page.
     
    longhornfreak, Sep 27, 2007 IP
  4. webdesigner

    webdesigner Well-Known Member

    Messages:
    489
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    110
    #4
    Ok, just to clear things up. You say you are on a Windows server, in that case you need to use ASP (ignore PHP as that only works on Linux Servers).

    The problem is, is that HTML pages can not do any server side includes (SSI), so your pages will need to renamed to .asp (eg index.html -> index.asp). All the code remains the same so you need to change nothing else. Now you have an .asp file you can do a server side include on your pages by just including the code:

    <!-- #include virtual="/recentupdates.asp" -->

    Replace the filename with whatever it actually is. So to breakdown, 3 simple steps.

    1. Rename your files from .html or whatever to .asp

    2. Include code <!-- #include virtual="/recentupdates.asp" --> to include that page.

    3.Thats it... nice and easy.
     
    webdesigner, Sep 27, 2007 IP
  5. Diminished29

    Diminished29 Peon

    Messages:
    81
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks Webdesigner rep for you. I did everything you said about 2 hours before this post and everything worked fine. Your post only insured that I got it right, so that makes me feel pretty good.

    Two quick questions:

    1. I read somewhere that ASP has some maintence issues and that ASP.NET is the better choice in the long run - is this true, and what kind of "problems" am I looking at here?

    2. I'd like to eventually allow users to post comments to the articles I put up on the site, however, with me using ASP instead of PHP, is there a MySQL equivlent since much of the comment based scripts need a database along side them to work properly or does ASP work ok MySQL?
     
    Diminished29, Sep 27, 2007 IP