Need instruction. Please.
Situation: Most of my site pages start with the following:

<?
include("include/common.inc.php");
top();
left();
middle();
bottom();
function middle(){
?>

My include/common.inc has the head, title, meta tags which means they look the same on EVERY single page of my site (hundreds of pages!). Not good for SEO.

Extract from include/common.inc:
<!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=iso-8859-1" /><title>This is just a quick show etc etc ……….</head>

Question: How do I safely move the <head> to each individual page so that I can customize the title and meta tags? I do not care how long it takes me. Where do I place the <head> on the pages, before <?, after, in between?

I tried to place the <head> at the top of each page and tried MANY other things, it does not work.

Note: I still need include/common.inc to be there since it holds lots of functions.

THANK YOU EVERYONE!!!!!!!!!!!!!

Natasha:icon_cheesygrin:

Recommended Answers

All 6 Replies

For the title, do this in each file:

define ("PAGE_TITLE", "Title for the Page");

And in common.inc put something like:

<title><? echo PAGE_TITLE; ?></title>

For the Meta tags, you could put together an array on each page like follows:

$page_meta_tags[] .= '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
$page_meta_tags[] .= '<meta name="description" content="stuff here" />';

And then in common.inc

foreach($page_meta_tags as $value) {
  echo $value;
}

This may need adjusting for your application, just an idea..

Your idea seemed perfect so I tried it right away. Unfortunatly I get this error. Any suggestion?

Question: Where exactly do you place the "define" function on each page? Perhaps that is my problem.

Thanks.

Natasha

ERROR MESSAGE:
Warning: include(include/site_functions.php) [function.include]: failed to open stream: No such file or directory in /home/content/d/o/r/dornhosting/html/include/common.inc.php on line 15

Warning: include() [function.include]: Failed opening 'include/site_functions.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /home/content/d/o/r/dornhosting/html/include/common.inc.php on line 15

This is where I put the define function one the page

<?
include("include/common.inc.php");
define ("PAGE_TITLE", "Title for the Page");
top();
left();
middle();
bottom();
function middle(){
?>

It is working GREAT now for the titles.

I am not sure what went wrong the first time.

Regardless ... this was the best peice of information I ever got.

THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Edit:
Apparanty the below is irrelevant since you say it now works. :)

-----------------------------
Does the file include/site_functions.php exist?

Can you post line 15 from common.inc and a few lines before and after it since this seems to be the cause of the problem if the file does exist.

If the <head> is echoed in the top() function then it should work as you have it, if it is echoed automatically by the common.inc then you should define the title before including the file.

hi there
please i want a Quick answer please
i dont know how to make the headline of my webpage move from the right to left i need it by html code please thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.