Solved

Header and footer template

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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

717 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