CUSTOM PAGE TITLE USING "title" & "subtitle" fields on current page?

4 posts by 3 authors in: Forums > CMS Builder
Last Post: April 29, 2013   (RSS)

By csdesign - April 22, 2013

Hello!  

I pulled the code I needed from the cmscookbook but I have a question.  I've tried, but can't get this to work.  

I would like the page title to come from the field "title" and "subtitle" on any given page (detail page, list page & single record pages)

Can I somehow make $pagesRecord generic so it would just pull the title from whichever page that showing in the browser?

<title><?PHP echo $pagesRecord['title']; ?>,<?PHP echo $pagesRecord['subtitle']; ?>Company Name Here</title>

My meta tag data is currently in my "include_header.php" file.
If there is a way to do this, I'm assuming I could do the same with the description and keyword fields also. 

Thanks so much!! Tina

By csdesign - April 23, 2013

Hi Jerry, 

Sure thing! 

I would like to be able to control the Title in the Meta Tags on the include_header.php page. 

In the Title tag in the meta tags, I would like to be able to use 2 already populated fields in a Single page record, Multi Page Record listing page or multi-page Details pages. 

Here's a test page for reference: 
http://www.superiorequinesires.com/stallion.php?DONNERHALL---TESTING-2

On this page/record, the page Title is "Donnerhall - Testing" and the page subtitle is "Oldenburg" (breed). 
I would like the page Title and the page Subtitle to be included in the title that appears at the top of the browser window (on sample page, it currently reads "superior equine sights/sires". 

I'd like it to read:  "Donnerall, Oldenburg, Superior Equine Sires"  by having the meta tag title automatically use my page title and page subtitle of that specific page only. (changes by page)

That's where I came up with this: 

<title><?PHP echo $pagesRecord['title']; ?>,<?PHP echo $pagesRecord['subtitle']; ?>Company Name Here</title>

Does that make more sense?  Thanks! Tina

Hi Tina, 

Did you resolve this issue? If not what about using something like this:

<?php $metaTitle = (@$pageRecord)?  $pagesRecord['title'].','.$pagesRecord['subtitle'].'Company Name Here' : 'Alternative title text here'; ?>
<title><?phg echo $metaTitle; ?></title>

So if $pageRecord is set before include_header.php is included, then in include_header you could detect if $pageRecord has been set, and if it hasn't display an alternative header instead, which in this example would be Alternative title text here.

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com