1 Reply Latest reply on Mar 9, 2010 9:37 AM by osgood_

    Common header

    rp1106

      I have designed a website. It's some 50 odd pages website right now. I would like use a common header and footer for all the pages. I don't know exactly how to do it. I googled it but couldn't find anything worthy. I heard it can be done in PHP and even in Jquery. Can anyone help on this ASAP? Thank you.

        • 1. Re: Common header
          osgood_ Level 8

          rp1106 wrote:

           

          I have designed a website. It's some 50 odd pages website right now. I would like use a common header and footer for all the pages. I don't know exactly how to do it. I googled it but couldn't find anything worthy. I heard it can be done in PHP and even in Jquery. Can anyone help on this ASAP? Thank you.

           

          Are you familar with simple php? If so then all you need to do is include a line of code (see below) in each page of the site where you want the header to be.

           

          <?php include("header.php"); ?>

           

           

          Create the header information in a seperate file and save it as header.php to your site folder. The include file should only include the code which is specific to the header, nothing else like <body>, meta tags etc.

           

          So for example if I just wanted a h1 heading all the code would look like is:

           

          <h1>This is the heading for this page</h1>

           

          Rather than the usual lot of rubbish:

           

           

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
          <title>Untitled Document</title>
          </head>

           

          <body>

          <h1>This is the heading for this page</h1>
          </body>
          </html>

           

           

          Of course this will only work if the server you're hosting the site on is running php and it would be quite nice to have a server set up locally for testing purposes.