Solved

Header and footer template

Posted on 2007-11-21
4
1,632 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 100 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 250 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

733 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