Jump to content

Create one header file for 70 - 80 pages


cookgran

Recommended Posts

:) Hello everyone,I have been looking over all the questions and answers on this forum and I am pretty impressed. Seems like no matter what the question, someone - usually 2, 3 or more - have an answer. I have a question about the best way to create 70 - 80 web pages that all have the same header and footer. Only differences are titles and of course page filename. I want to make one header file - which includes some javascript, images, links, etc. - and use it for all the pages. Same with the footer. I have been looking for a while, and have not figured out how to do it. Anyone have any ideas?? All ideas will be greatly appreciated.
Link to comment
Share on other sites

on the page that has the include:

include "header.php?title={$_SERVER['PHP_SELF']}";

on the included page:

<html><head><title><?php$title = $_GET['title'];$title2 = eregi_replace(".php", "", $title);echo $title2;?></title>

But thats only if you want the pages title to be the filename without the ending file type, I always name my files .php, unless if you have your php.ini file set up to parse php in .html files. Then just replace ".php" with ".html". Glad you like the forums!

Link to comment
Share on other sites

well, I think we better give a bit more info.First of all, to use reportingsjr's example and the one I'm about to show you, you need to have PHP enabled on your webhost.first you make yourself a header file, and a footer file.let's say the header file looks like this:

<html><head><title><?php echo $pagename; ?></title><script src="myscriptiwantineverypage.js"></script></head><body>

you know, just the basic head of a page. that <?php echo $pagename; ?> is what's going to give you a different title on each page.then you have the basic footer. (I'm not going to give an example on this one.)then you have each file, that are different, and they look something like this:

<?php $pagename = "Mytotallyrediculouslylongtitle!!!";include("header.php"); ?>this is some content that will change on each page....this is some content that will change on each page....this is some content that will change on each page....<?php include("footer.html"); ?>

of course, you have to change Mytotallyrediculouslylongtitle!!! to whatever you want your title to be, and header.php to whatever the filename of your header is, and footer.html to whatever the filename of your footer is.have I confused you enough? :) you really should get a basic understanding of php before you try this though.LG

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...