?
Solved

Header and footer template

Posted on 2007-11-21
4
Medium Priority
?
1,642 Views
Last Modified: 2012-06-21
Hi,

I am planning building web site and it is relatively static. I need to insert a little bit of php code for members credentials and member's board section. There won't be many pages, but every pages will contain identical header and footer and etc and I don't want to repeat identical sections for every page. I know how to that in JSP and other language, but this web site doesn't have to be really dynamic, so I am going with html/php.
 Is there sort of 'master template' technique that will affect all pages?

thx,
0
Comment
Question by:dkim18
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 20

Assisted Solution

by:steelseth12
steelseth12 earned 400 total points
ID: 20332846
Put your header information e.g
<html><head><tltle> etc all common code in a file called header.php
All your footer information in a file called footer.php

and the just include them in the rest of your pages

e.g

require("header.php");

Code for your page

require("footer.php");
0
 
LVL 21

Accepted Solution

by:
nizsmo earned 1000 total points
ID: 20333099
You can also include files which are not .php in extension, something like:

require("myfile.html");

will also work.

And just incase and make sure you don't include or require the same file twice, you can use the:

require_once("myfile.html");

and this will only include the file once.

hope this helps.
0
 
LVL 6

Expert Comment

by:nitinsawhney
ID: 20333717
You should add the <html>...<body> tag to the header.html  and </body></html> in footer.html.

I some times require that the title, meta tags of the pages to be different.
In that case it is advisable *not to* include <html></html> tags in your header and footer files.

so they would look something like
<table>
<tr><td><img src="header.jpg"></td></tr>
</table>

Now you could have a custom page and include this file where ever required in your code as described by steelseth12 and nizsmo. Preferably require_once is a good option in this particular case.

Cheers
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 20334879
are you looking for predefined templating system for your site?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question