How do I add sitewide sidebar into static Html page?

Discussion in 'HTML & Website Design' started by super, Oct 8, 2007.

  1. #1
    Hi, I build static html pages, but I would like to have sitewide sidebar with links - so that it won't be needed to edit every html page when I need to change something in sidebar.
    How could I do sitewide sidebr?
    thanks
     
    super, Oct 8, 2007 IP
  2. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #2
    You can use server side includes (if your host allows), or frames. There are some problems (which I'm sure everyone will chime in about) with frames, but they work.
     
    lektrikpuke, Oct 8, 2007 IP
  3. super

    super Well-Known Member

    Messages:
    1,019
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    130
    #3
    ok i heard something about php include, but how do I do that? Any tutorial? I imagine building sidebar with html and include it somehow, but not sure about php..
     
    super, Oct 8, 2007 IP
  4. longhornfreak

    longhornfreak Well-Known Member

    Messages:
    2,067
    Likes Received:
    95
    Best Answers:
    0
    Trophy Points:
    140
    #4
    Code everything for your site. Then where you want your side bar to be, create a div and add this in the div
    
    <?php 
           include ( "includes/sidebar.php") 
    ?>
    
    Code (markup):
    Then create a directory on your FTP, name it includes.

    Create a file sidebar.php and add your code there, then you just update that each time.


    your pages are going to have to be php pages I believe, but all you will change is <php at the top and ?> at the end of every page, and the .php file extension, everything inside of it will be xhtml though

    I don't know much php so its hard to explain how to do this.
     
    longhornfreak, Oct 8, 2007 IP
  5. super

    super Well-Known Member

    Messages:
    1,019
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    130
    #5
    Thanks lol and I don't know php at all so its not so easy for me as well :)
     
    super, Oct 8, 2007 IP
  6. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #6
    SSI is pretty much the same as PHP includes except you name all the files with the extension shtml (instead of htm or html) and everything is programmed as regular html (not that PHP is bad). The include statement is:
    <!--#include virtual="folder_where_file_located/file_2_include_name.shtml" -->
     
    lektrikpuke, Oct 8, 2007 IP
  7. WM7

    WM7 Peon

    Messages:
    778
    Likes Received:
    112
    Best Answers:
    0
    Trophy Points:
    0
    #7
    if you dont want to use php then framing is the answer.
     
    WM7, Oct 9, 2007 IP
  8. PHPGator

    PHPGator Banned

    Messages:
    4,437
    Likes Received:
    133
    Best Answers:
    0
    Trophy Points:
    260
    #8
    Do not use frames! Heck, i'll make the changes for you for free in PHP just to keep you from making such a horrible mistake. :)
     
    PHPGator, Oct 9, 2007 IP
  9. Stretsh

    Stretsh Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I think your solution depends on what the server supports. If it does support php, I would suggest you use php.

    But in that case, your include files (sidebar in this case) may just be an html file. The including file on the other hand (ie every page that will need to include the sidebar) will need to have the .php extension instead of just html.

    There are a lot of easy php tutorials available online, just google 'php tutorial'.
     
    Stretsh, Oct 9, 2007 IP
  10. super

    super Well-Known Member

    Messages:
    1,019
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    130
    #10
    so what you saying is that I must redo all my site pages from html format to php just to be able to use php include function?
     
    super, Oct 9, 2007 IP
  11. Stretsh

    Stretsh Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    You only need to change the extension from .html to .php.
     
    Stretsh, Oct 9, 2007 IP