WEB Easiest way of inserting header.htm into 50+ html pages?

Discussion in 'OT Technology' started by Vistrix, Jan 29, 2008.

  1. Vistrix

    Vistrix So Say We All

    Joined:
    Aug 17, 2005
    Messages:
    12,623
    Likes Received:
    0
    Location:
    Wales
    Ive been trying to look up Ajax but its a nightmare. The documentation sucks.

    Can someone suggest an easy way of inserting the same html code ( the header menu) into every page, preferably not using PHP or ASP.

    Im a beginner here. Thanks.
     
  2. GotVtec

    GotVtec 8th World Wonder

    Joined:
    Mar 14, 2000
    Messages:
    575
    Likes Received:
    0
    Location:
    Omaha, NE
    Code:
    <!--#include virtual="/path/to/header.html" -->
     
  3. Vistrix

    Vistrix So Say We All

    Joined:
    Aug 17, 2005
    Messages:
    12,623
    Likes Received:
    0
    Location:
    Wales
    Not using PHP...
     
  4. telc

    telc OT Supporter

    Joined:
    Aug 29, 2003
    Messages:
    18,580
    Likes Received:
    0
    Does the server not support PHP? You could do it with 1 line of code on the top of each page.

    Code:
    <? include("header.html"); ?>
    
     
  5. telc

    telc OT Supporter

    Joined:
    Aug 29, 2003
    Messages:
    18,580
    Likes Received:
    0

    Because Ajax isn't ment for that purpose, and you will end up slowing the page load, when it had to request the header separately. Instead of already having it include when the browser received it.
     
  6. Vistrix

    Vistrix So Say We All

    Joined:
    Aug 17, 2005
    Messages:
    12,623
    Likes Received:
    0
    Location:
    Wales
    I was looking at the prototype script...I thought thats exactly what its for.
     
  7. Vistrix

    Vistrix So Say We All

    Joined:
    Aug 17, 2005
    Messages:
    12,623
    Likes Received:
    0
    Location:
    Wales
    Wouldnt I have to have all the .htm pages as .php though?
     
  8. telc

    telc OT Supporter

    Joined:
    Aug 29, 2003
    Messages:
    18,580
    Likes Received:
    0
    no, your server can be configured to process any extention as php. It probably already has .html setup.

    Create a test.html and put in <? echo "Test"; ?> and load it from browser and see what happens.
     
  9. Vistrix

    Vistrix So Say We All

    Joined:
    Aug 17, 2005
    Messages:
    12,623
    Likes Received:
    0
    Location:
    Wales
    I get nothing. Blank page.
     
  10. telc

    telc OT Supporter

    Joined:
    Aug 29, 2003
    Messages:
    18,580
    Likes Received:
    0
    Is it Apache or IIS? Window or Linux?

    Assuming your server has Apache installed with PHP and you don't have access to the httpd.conf file. Try creating a file called .htaccess in the same directoy as your html files, and put this line in it.

     
  11. Vistrix

    Vistrix So Say We All

    Joined:
    Aug 17, 2005
    Messages:
    12,623
    Likes Received:
    0
    Location:
    Wales
    Ok, how can I create a .htaccess file with no file name? .xxx is the extension right?
     
  12. telc

    telc OT Supporter

    Joined:
    Aug 29, 2003
    Messages:
    18,580
    Likes Received:
    0
    Is it a linux or windows server? Its hard to help out without know all the details of your server configuration. Do you have cpanel or some kind of admin page to manage the server?
     
  13. Vistrix

    Vistrix So Say We All

    Joined:
    Aug 17, 2005
    Messages:
    12,623
    Likes Received:
    0
    Location:
    Wales
    Its a Debian linux server. Hosted with Dreamhost, it says it supports PHP4 & 5.

    On the Cpanel it says:

     
  14. telc

    telc OT Supporter

    Joined:
    Aug 29, 2003
    Messages:
    18,580
    Likes Received:
    0
    Create the .htaccess file with that line I showed you, it should work.
     
  15. Vistrix

    Vistrix So Say We All

    Joined:
    Aug 17, 2005
    Messages:
    12,623
    Likes Received:
    0
    Location:
    Wales
    Ok well it wont let me create an .htaccess file via FTP. It says it needs a filename.

    It has to be abc.htaccess or htaccess
     
  16. telc

    telc OT Supporter

    Joined:
    Aug 29, 2003
    Messages:
    18,580
    Likes Received:
    0
    Create the file in notepad, save it as .htaccess and upload it.
     
  17. Vistrix

    Vistrix So Say We All

    Joined:
    Aug 17, 2005
    Messages:
    12,623
    Likes Received:
    0
    Location:
    Wales
    Ok I was trying to rename the .txt file rather than saving it as...nevermind lol

    I uploaded a .htaccess file with the text and still have a blank page, does it take a while?
     
  18. Vistrix

    Vistrix So Say We All

    Joined:
    Aug 17, 2005
    Messages:
    12,623
    Likes Received:
    0
    Location:
    Wales
    The .htaccess has just dissapeared from the server folder, is that right?
     
  19. telc

    telc OT Supporter

    Joined:
    Aug 29, 2003
    Messages:
    18,580
    Likes Received:
    0

    Its a hidden file if it has . before it. You if you SSH in and do a ls -la you will see it. Did it work?
     
  20. Vistrix

    Vistrix So Say We All

    Joined:
    Aug 17, 2005
    Messages:
    12,623
    Likes Received:
    0
    Location:
    Wales
    Didnt do shit lol test.htm is just a blank page.
     
  21. telc

    telc OT Supporter

    Joined:
    Aug 29, 2003
    Messages:
    18,580
    Likes Received:
    0
    Can't help you, contact dreamhost support and tell you want want .htm and .html to parse as php files.
     
  22. Vistrix

    Vistrix So Say We All

    Joined:
    Aug 17, 2005
    Messages:
    12,623
    Likes Received:
    0
    Location:
    Wales
    Alright, thanks. Ill contact them now.

    Everytime I try something as easy as this in programming something always goes wrong :o confuses the fuck out of me.
     
  23. telc

    telc OT Supporter

    Joined:
    Aug 29, 2003
    Messages:
    18,580
    Likes Received:
    0
    You may want to delete the .htaccess you created or have them do it.
     
  24. maxxpower

    maxxpower OG Lauren Crew - Observer OT Supporter

    Joined:
    May 27, 2007
    Messages:
    26,348
    Likes Received:
    0
    Do you not have a "php" option in the cpanel that allows you to add a new extention to php?
    Example, mine has php, php3 etc and an option to add any extention to be parsed as php.
    I havent tried adding .htm or .html to the list, but I am assuming it works.
     
  25. Kewlb

    Kewlb New Member

    Joined:
    Nov 21, 2002
    Messages:
    1,510
    Likes Received:
    0
    this is what you are looking for and that IS NOT php/asp it is just a markup code to tell the html page to insert the code contained in header.html into that exact section of the html file you insert it in.

    you can also do
    Code:
    <!-- #include file="/path/to/header.html" -->
     

Share This Page