Solved

Header and footer template

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now