Using titles in header file

5 posts by 3 authors in: Forums > CMS Builder
Last Post: May 23, 2009   (RSS)

By Thomas - May 18, 2009

Hi,

Is it possible to use the title of the page in a generic site wide header file?
I have managed to get this working with all pages in a category but any other categories it will not work.

For example:

http://76.163.37.133/ivf/index.php?RBA-History-4
Works and includes 'RBA HISTORY' in the title

http://76.163.37.133/ivf/newslist.php
Does not include a title instead 'Notice: Undefined variable: pagesRecord in .../rba-online.com/ivf/header.php on line 6'

http://76.163.37.133/ivf/news.php?Breakthrough-in-Egg-Freezing-1
This is a different category too, again no title.

Is there a work around I can use?

Thanks

Re: [ross] Using titles in header file

By Thomas - May 19, 2009

Hi Ross,

Thank you for your response.
I would actually like to have a separate title for each page mainly for SEO reasons. I can actually do that with a php include after the code on the php page...


<?php

require_once "/rba-online.com/ivf/lib/viewer_functions.php";

list($pagesRecords, $pagesMetaData) = getRecords(array(
'tableName' => 'pages',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$pagesRecord = @$pagesRecords[0]; // get first record

?>

Then in 'header.php'

<title><?php echo $pagesRecord['title'] ?></title>


and this will provide a unique title for 80% of the site.

What I would like is either;
i) to be able to do something that would call the title form the other pages in other sections or
ii) If a title is not able to be displayed put a generic title there instead.

Does this make sense?

Many thanks

Re: [Thomas] Using titles in header file

By zip222 - May 19, 2009

replace your header.php file with this...

<?php if($pagesRecord['title']): ?>
<title><?php echo $pagesRecord['title'] ?></title>
<?php else: ?>
<title>GENERIC TITLE</title>
<?php endif; ?>

Re: [jdancisin] Using titles in header file

By Thomas - May 23, 2009

Thank you jdancisin,
I'll give that a try