You are here: PHP includes -- unique title and meta tags for each page « All PHP « IT news, forums, messages
PHP includes -- unique title and meta tags for each page

Posted by jl on 06/30/05 01:28

I am using includes so that the content on each page is loaded from other
PHP files in an /includes directory. I would like to know how to make the
title and meta tags of each page be unique also. I'm not sure how to make
this work correctly.

This is a sample of my HTML head in a file called header.php:

<head>
<title><?php echo $page_title; ?></title>
<meta name="description" content="<?php echo $meta_description; ?>" />
<meta name="keywords" content="<?php echo $meta_keywords; ?>" />
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>

This is how the index.php file is set up. It includes separate 'header'
(containing the HTML head and navigation) and 'footer' files:

<?php

// How do I make it so that these variables are unique for each page and can
be read by the header.php file?
$page_title = 'Page title here';
$meta_description = 'meta description here';
$meta_keywords = 'meta keywords here';

// Header file
include ('header.php');

// To add more pages to this website as includes, you must add them to this
array:
$allowedpages = array("default.php", "etc.php");
$pagina = "default.php";
$allowed = false;
if(isset($_GET['p'])){
$newpage = $_GET['p'].".php";
for($i=0;$i<count($allowedpages);$i++){
if($newpage == $allowedpages[$i]) $allowed = true;
}
if($allowed && file_exists("includes/".$newpage)){
include("includes/".$newpage);
} else {
include("includes/redirect.php");
}
} else {
include("includes/".$pagina);
}

// Footer
include ('footer.php');
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация