I have just started using php includes on my website to help me propagate changes across an entire site. So far I have set up include for 3 parts of my site. The header, footer and the navigation, as these are quite likely to change on a regular basis.
I would also like to include the <head> as another section that is mostly recurring across the entire site. The problem is that parts of the <head> will be unique to certain pages. Example:
<meta charset="utf-8">
<meta name="description" content="Unique decription for my homepage.">
<meta name="keywords" content="Some keywords recur, but not all of them.">
<title>This is unique to the Home page.</title>
<link rel="icon" type="image/ico" href="/resources/images/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="/resources/stylesheets/main.css"/>
<link rel="stylesheet" type="text/css" href="/resources/stylesheets/nav.css"/>
<meta charset="utf-8">
<meta name="description" content="Unique decription for my gallery.">
<meta name="keywords" content="Some keywords recur, but not all of them.">
<title>This is unique to the Gallery page.</title>
<link rel="icon" type="image/ico" href="/resources/images/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="/resources/stylesheets/main.css"/>
<link rel="stylesheet" type="text/css" href="/resources/stylesheets/nav.css"/>
The only way I can think of dealing with this is to include the head and use variables, btw this is pseudocode, I guess you cant just drop variable names in, like this:
<meta charset="utf-8">
<meta name="description" content="$homeDescr">
<meta name="keywords" content="$homeKeyw">
<title>$homeTitle</title>
<link rel="icon" type="image/ico" href="/resources/images/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="/resources/stylesheets/main.css"/>
<link rel="stylesheet" type="text/css" href="/resources/stylesheets/nav.css"/>
I would include the <head> like this (the normal way?):
<?php $path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/resources/recurring/head.php";
include_once($path); ?>
But I would like to save the variables in a file called variables.php, which would look something like:
$homeDescr="My site offers a super service in the ballpoint pen industry!";
$homeKeyw="ball point ballpoint pen pens super service cheap fast delivery";
$homeTitle="Welcome to Ballpointland! - Home";
$galleryDescr="Look at the great pens we have on offer!";
$galleryKeyw="ball point ballpoint pen pens super pictures photos images gallery";
$galleryTitle="Welcome to Ballpointland! - Gallery";
And so on...
I'm completely newb at php and dont know how including a file that includes variables form another file would work, or even if it would work at all.
I would like it to work in this way because then I could just go to variables.php to update a great deal of meta tags and titles from one place. If it is easier to handle those variable inside head.php then ok.
Please help!
PS. I don't sell ballpoint pens :P