Change document title
Posted: Thu Jan 22, 2009 5:24 pm
Hello all,
Nooberiffic here. Just trying to utilize PHP for the first time. I'm not doing anything "real php-like" at this point. Having a bit of a problem using the include construct, and page titles. So I'm building a site utilizing include to append the header and footer to each content page. Working wonderfully.
However, I'm implementing site search functionality via "free find" and I'm having an issue with the returned results. They all have the title defined on header.php. The search results are correct and works wonderfully, it just doesn't look appealing when every result has the same title. So I first tried to tackle this in JS and it worked to change the title onload of each content page, but not in the results. So then I tried to tackle this via PHP and thought I had something that would work, but I can't seem to make it happen. Any light you guys could shed on this would be much appreciated. This is my first attempt with PHP and the site is not DB-driven.
Here is the PHP I've tried...
...in header.php...
...in each content.php...
The result is an empty <title></title>
Thanks again
wheatleyweb
Nooberiffic here. Just trying to utilize PHP for the first time. I'm not doing anything "real php-like" at this point. Having a bit of a problem using the include construct, and page titles. So I'm building a site utilizing include to append the header and footer to each content page. Working wonderfully.
However, I'm implementing site search functionality via "free find" and I'm having an issue with the returned results. They all have the title defined on header.php. The search results are correct and works wonderfully, it just doesn't look appealing when every result has the same title. So I first tried to tackle this in JS and it worked to change the title onload of each content page, but not in the results. So then I tried to tackle this via PHP and thought I had something that would work, but I can't seem to make it happen. Any light you guys could shed on this would be much appreciated. This is my first attempt with PHP and the site is not DB-driven.
Here is the PHP I've tried...
...in header.php...
Code: Select all
<title><?php echo $pageTitle?></title>Code: Select all
<?php
$pageTitle = "Whatever you want the page title for this page to be";
?>Thanks again
wheatleyweb