Another way to do it is to have a key (number) hardcoded into the top of each page.
mypage.php
PHP Code:
<?php
$page = 23;
include 'header.php';
include 'navigation.php';
?>
// do your static html body content here
<?php
include 'footer.php';
?>
Then in header.php maintain an array of values and output them into the header html stream.
header.php
PHP Code:
<?php
$meta = array(
1 => array(
'title'=>'Title for page one',
'keywords'=>'page, one',
'descrip'=>'This is page one',
),
// etc
23 => array(
'title'=>'Title for page twenty three',
'keywords'=>'page, twenty, three',
'descrip'=>'This is page twenty three',
),
);
?>
<html>
<title><?=$meta[$page]['title']?></title>
<meta name=keywords value='<?=$meta[$page]['keywords']?>' />
<meta name=keywords value='<?=$meta[$page]['descrip']?>' />
I've left lots out here, like checking if key 23 actually exists prior to trying to echo it. It also presumes you have PHP short tags ON, otherwise you'd have to do this:
PHP Code:
<title><?php echo $meta[$page]['title']; ?></title>
You can then go on expanding this idea, put the header code into a function, output some default values if the $page key is missing, you could store the arrays as an ini file -- eventually you may find it easier to put the values in a database however.
Keywords might benefit from being held in a db, if you wanted to sort your pages by keyword, for example.
Bookmarks