Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Header and footer template

Posted on 2007-11-21
4
Medium Priority
?
1,646 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

Industry Leaders: 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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

610 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