Normally when I "include" a file it contains variables that my main page is using so it seems a little odd that your include file is just echoing the value. Sometimes scripts will be built to include a head.php file in the main page but within that head.php there is another included file like a config.php file that references all the site details and such. ie. a content management system may use something similar or the head info is pulled from a database.
It seems logical but I can't offer an explanation on why only 1 set of the code in your last post works, and why the 2nd setup doesn't. Query strings(getting info from URL)(simple switch statement could even be applied) or a database might be the only option to update the meta data dynamically on all your static pages.
The head data will pretty much remain the same on each page so if you really want to keep the meta tags and echo them out in a seperate file it might be just as easy to do something like this...
Create all your static pages in a similar format and change your meta info at the top, and the included file head.php is seperate and echos the common meta info. Anytime you create a new file you update the php info at the top in that one file which is really the same as coding it in html but using php variables and echoing them out.PHP Code:<?php
$pageTitle="Reel Lumber Service | Wholesale Hardwood & Pine Lumber, Mouldings, Plywood, Custom Milling";
$pageDescription = "speculative website build";
$pageKeywords = "adrian testa-avila, custom-anything, custom, web, web design, web site, html, css, php, javascript";
$pageRobots = "noindex, nofollow";
//end of content changes for each page
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<?php include ("/path/to/head.php"); //head only echos the meta tags ?>
<!-- if you wanted to add other meta info on a specific page you could do it here -->
</head>
<body>
</body>
</html>



Reply With Quote

Bookmarks