How to use one header + footer for all my pages?

Discussion in 'HTML & Website Design' started by Johnburk, Jan 6, 2006.

  1. #1
    How can you make a page where you always use one header and one footer.

    So despite how many pages you have, you only have to edit one header and one footer and then it is automaticly applied to all the pages.

    How can this be done?
     
    Johnburk, Jan 6, 2006 IP
  2. just-4-teens

    just-4-teens Peon

    Messages:
    3,967
    Likes Received:
    168
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if your using php you could use.

    <?php include('header.php'); ?>
    PHP:
    <?php include('footer.php'); ?>
    PHP:
    place within file.php where you wish for header.php & footer.php to be shown.

    of course header & footer can be re-named to whatever you wish.

    so your page would look like

    <?php include('header.php'); ?>
    Main page content
    <?php include('footer.php'); ?>
    PHP:
     
    just-4-teens, Jan 6, 2006 IP
  3. n0other

    n0other Peon

    Messages:
    146
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Website is static or dynamic? For a static website, look in the programming forums for digitalpoints mod_rewrite hack, that let's you achieve it. Otherwise, look into mod_layout (both are for apache of course). If your website is dynamic, the easiest way would be to wrap the content around header and footer, so that it's only the content that change when loading different pages. From the question, I assume you don't have any programming experience, so I will not give any examples. Ask in the programming forum if you feel the need for them.
     
    n0other, Jan 6, 2006 IP
  4. Johnburk

    Johnburk Peon

    Messages:
    777
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    @just-4-teens
    That looks simple :D, so what if its html?

    @n0other
    What do you mean with static or dynamic?
     
    Johnburk, Jan 6, 2006 IP
  5. Corey Bryant

    Corey Bryant Texan at Heart

    Messages:
    1,126
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You can use Server Side Includes as well.

    I have been using ASP mainly to take advanatge of the ASP include function. But SSI is pretty easy to implement and might be able to help you out
     
    Corey Bryant, Jan 6, 2006 IP
  6. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If its html you need to alter your .htaccess file to process html as a php file

    Static is page.html or page.php
    Dynamic is page.php?section=1
     
    dave487, Jan 6, 2006 IP
    Johnburk likes this.
  7. just-4-teens

    just-4-teens Peon

    Messages:
    3,967
    Likes Received:
    168
    Best Answers:
    0
    Trophy Points:
    0
    #7
    If its .html/.htm pages, then there is a way around it using .htaccess & mod_rewrite (you might find some info here http://forums.digitalpoint.com/forumdisplay.php?f=49) basicly what it does is parse static html pages as dynamic php.

    ---
    wait i found it :)
    Add this to your .htaccess file.
     
    just-4-teens, Jan 6, 2006 IP
    Johnburk likes this.
  8. Johnburk

    Johnburk Peon

    Messages:
    777
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks everyone. I am going to try it and let you know.

    Is is all static.
     
    Johnburk, Jan 6, 2006 IP
  9. Johnburk

    Johnburk Peon

    Messages:
    777
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #9
    It works :D :D :D
     
    Johnburk, Jan 6, 2006 IP
  10. just-4-teens

    just-4-teens Peon

    Messages:
    3,967
    Likes Received:
    168
    Best Answers:
    0
    Trophy Points:
    0
    #10
    congrats :D

    you learn something new everyday
     
    just-4-teens, Jan 6, 2006 IP
  11. n0other

    n0other Peon

    Messages:
    146
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #11
    I guess it's already too late, but by dynamic I refer to a website which has its output generated on the go (or in other words dynamically, depending on user's actions usually)
     
    n0other, Jan 6, 2006 IP