Forums

PHP

This topic is locked

Page Title Issue

Posted 04 May 2009 21:07:45
1
has voted
04 May 2009 21:07:45 Laura Lacy posted:
I'm really new to PHP and I've inherited a site written completely with PHP and I know nothing about it. The boss wants me to make changes to the title. Right now, the same title appears on each page and we want unique titles on each page. After some investigation, I discovered that the predecessor had written the meta data into the functions.php document. This is overriding any changes I make to the individual pages. (I've also discovered that this is an issue with our meta descriptions as well.)

Is there a way that I can have it pull the page titles (or later descriptions) from the individual documents?

Thanks!

Here's the section of code for the functions page:

<?php

function insertHeader($path) {
echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Executive Search Firm | Inc.</title>
<meta name="description" content="The leading executive search firm in the building materials and kitchen/bath industries." />
<meta name="keywords" content="executive recruiters, executive recruiter, recruiters, recruiter, head hunter, headhunter, executive search, executive search firm, search firm, career, careers, job, jobs, interview, interviews, job interview, building materials, kitchen, bath, baths, whirlpool bath, whirlpool baths, windows, doors, cabinets, cabinet accessories, plumbing, plumbing fixtures, decorative plumbing, solid surfaces, solid surface materials, countertops, lighting, roofing, pool, spa, spas, hardware, builder hardware, building hardware, paint, appliances, consumer electronics, wilsonart, corian, formica, laminates, closets, closet organizers, lawn and garden, lawn, garden, automotive, packaging" />
<meta name="Copyright" content="All Images, Flash, Copy and Code copyright 2008 Brooke Chase Associates, Inc." />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="shortcut icon" href="' . $path . 'img/favicon.ico" type="image/x-icon" />
<link href="' . $path . 'css/display.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 6]>
<link href="' . $path . 'css/ie6.css" rel="stylesheet" type="text/css" />
<![endif]-->
<script src="' . $path . 'js/collapse.js" type="text/javascript"></script>
<script src="' . $path . 'js/jquery.js" type="text/javascript"></script>
<script src="' . $path . 'js/jquery-config.js" type="text/javascript"></script>
</head>
Edited by - Laura Lacy on 04 May 2009  21:11:49

Replies

Replied 07 May 2009 12:15:01
07 May 2009 12:15:01 Alan C replied:
Hi Laura,
this is somewhat similar to something I did, pages generated from a template with php, then I ran into exactly this issue, all the titles and keywords were the same. The site's traffic plummeted :-( which is how we were alerted.

What I did was to modify the php script that generates the pages. In the original it took the header like yours does, from a template file. In the modified version it starts by reading the existing page's source file, then extracting the title, keywords and description tags, these are preserved, next the new page is generated and those preserved tags are inserted. Voila!

Now you can simply change the tags in the source of each page as you like with a text editor and every time the page gets regenerated they are propagated into the new version.

This is not the easiest application to start you off with php :-)

Reply to this topic