Skip navigation
scharger
Currently Being Moderated

How do I Create a Header & Footer Template

Feb 25, 2013 11:15 AM

Hi,

  I'm trying to Create a Header Template and a Footer Template, to make my PHP scripting eaiser.

 

So a simple Header Template -- Header.dwt

<!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>

 

A simple Footer Template -- Footer.dwt

</body>

</html>

 

I have a more complex header & footer I just wanted to do that to keep it simple.

 

Reason for doing this:

  • When I'm NOT using PHP in a Page I would like to throw on the footer.dwt & header.dwt on the html document.
  • When I am using PHP
    • I can put header.dwt into header.html, as a raw file.
    • I can put footer.dwt into footer.html, as a raw file.
    • and "<?php include ('footer.html'); ?>" when I need to close a part of the script
  • I want to do this because, all I have to do is edit one file and all of the other files are change, and cancel out the bussy work.

 

But I get an ERROR when I try to drop the Template into the HTML doc:

Error: " Unbalanced body tag "

 

Thanx for your help,

Andrew

 
Replies
  • Currently Being Moderated
    Feb 25, 2013 11:26 AM   in reply to scharger

    Don't use Templates for this.  Use Server-Side Includes.  They're cleaner & faster to update.

    http://www.smartwebby.com/web_site_design/server_side_includes.asp

     

    Template.dwt files are whole pages with Editable Regions for content that changes from page to page.   Everything outside Editable Regions is populated to all child pages spawned from that Template.  In other words, one Template contains site wide menus, common headers, footers, and anything else you want to appear on all your site pages.

     

    You would never, ever want to nest Templates (ie. one template for header, one for footer) as this would create an horrific mess.

     

     

    Nancy O.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2013 3:56 PM   in reply to scharger

    Like I said in the first sentence, use Server-Side Includes.

     

    <!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>

    <title>Your Site -- Page Name</title>

     

    <!--this is a php server-side include statement-->

    <?php require_once('Includes/head.html'); ?>

    </head>

     

    <body>

    <p> Where head.html and footer.html are seperate include files with relevant code in them.</p>

     

    <!--this is a php server-side include statement-->

    <?php require_once('Includes/footer.html'); ?>

     

    </body>

    </html>

     

     

     

    Nancy O.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2013 4:47 PM   in reply to scharger

    I already new that, but that still doesn't answer my question.

    If you KNEW that you wouldn't keep asking the same question which I HAVE answered 3 times?

    http://www.smartwebby.com/web_site_design/server_side_includes.asp

     

    Does anyone else have a idea...

     

    On how to create a Header & footer file that you only have to edit once.

    I repeat, with  S-E-R-V-E-R   S-I-D-E   I-N-C-L-U-D-E   F-I-L-E-S. 

    Google it.

     

    Good luck with your projects!

     

    Nancy O.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points