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: [Thomas] Using titles in header file

By ross - May 19, 2009

Hi Thomas

Thanks for posting!

You can have a generic site wide header that is easy to change. What you'll want to do though is just create a new single page section in your admin. You can call it Globals or something like that. It doesn't really matter.

In that section, create one field called Header (it can be a textfield).

Then all you need to do is put its viewer code on each of your pages and all the titles can be the same for your site.

Does that make sense? Does it sound like that would work for you?

Let me know :).
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

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; ?>