mmad Posted September 3, 2008 Share Posted September 3, 2008 Guys, I had a developer working on my header.php file contained in all of my webpages of a site we have. Our issue was that the header include did not allow us to have separate page titles and meta data...like descriptions and keywords. See below for what they provided. I have not been able to contact them to see how I can actually implement what the offered as a solution. Any help is much appreciated. <?php $filePath = $_SERVER['SCRIPT_NAME']; if (preg_match('/.*\/(.*)/', $filePath,$arrPage)) { $page = $arrPage[1] ; } if ($page == "index.php") { echo('<meta http-equiv="Content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Language" content="en"/>'); }elseif($page == "page2.php") { // you will type here } elseif($page == "page3.php") { // you will type here } ?> Link to comment https://forums.phpfreaks.com/topic/122473-headerphp-issue-and-programmatic-updating-of-title-and-meta-data/ Share on other sites More sharing options...
timmah1 Posted September 3, 2008 Share Posted September 3, 2008 Not sure about that code, but what I do for separate page titles is have the title echo out the title of each page. For instance <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo $page_title; ?></title> . . ..... would be your header page. Then, on every page, you would start it out like (about.php) <?php session_start(); $page_title = 'About Us'; require("header.php"); ?> Then, every time that page is loaded, the title would be About Us Hope that helps Link to comment https://forums.phpfreaks.com/topic/122473-headerphp-issue-and-programmatic-updating-of-title-and-meta-data/#findComment-632436 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.