Meta Titles, keyword and description

7 posts by 3 authors in: Forums > CMS Builder
Last Post: September 27, 2008   (RSS)

Hello everyone.

I am looking for a way to get the page browser title to reflect the title of the page, and I would also likt to add meta keywords and descriptions to each post. I followed the instructions from a previous thread, but they didn't work for me. I think those instructions were from the previous release of CMSB, as it was dated in July. Is there an easy way to do this?

Re: [thedmp] Meta Titles, keyword and description

By Donna - September 25, 2008 - edited: September 25, 2008

Hi thedmp!

Adding title, meta description and meta keyword tags really is almost as easy as adding them into the HTML directly.

Normally, you'd have something like this:

<head>
<title>Awesome Site Title</title>
<meta name="Description" content="Description of your awesome site" />
<meta name="Keywords" content="awesome site keywords" />
</head>

...or something like it. :)

So, the bits that you would replace would be the actual changing content.

First, setup new fields in CMS Builder for Title, Keywords & Description. Then, based on what field names you chose, you would wind up with something like this:

<head>
<title><?php echo $record['title'] ?></title>
<meta name="Description" content="<?php echo $record['metadescription'] ?>" />
<meta name="Keywords" content="<?php echo $record['metakeywords'] ?>" />
</head>


All I'm doing here is replacing my "filler" text with the generated php I copied directly from the code generator. (Of course, make sure you have all of the other required code on the page as well.)

Give that a try and let me know if it works for you. :)
Donna

--
support@interactivetools.com

Re: [Donna] Meta Titles, keyword and description

Hey, Donna. Thanks for the reply. I have been doing websites for nearly ten years--using different scripts and html, but I simply cannot figure this simple task out. I get a error that says "Notice: Undefined variable:record in {then it gives my website path}

Here is my CMS code:

<?php

require_once "/home/pctechby/public_html/support/lib/viewer_functions.php";


list($hpRecords, $hpMetaData) = getRecords(array(
'tableName' => 'hp',
));


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
body { font-family: arial; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>
<body>


<!-- INSTRUCTIONS -->
<div class="instructions">
<b>Sample List Viewer - Instructions:</b>
<ol>
<?php ?>
<li><b>Remove any fields you don't want displayed.</b> (Most list pages only have title and link fields.)</li>
<li>Rearrange remaining fields to suit your needs.</li>
<li>Copy and paste code into previously designed page (or add design to this page).</li>
</ol>
</div>
<!-- /INSTRUCTIONS -->


<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>hp - List Page Viewer</h1>
<?php foreach ($hpRecords as $record): ?>
pageTitle: <?php echo $record['pagetitle'] ?><br/>
Keywords: <?php echo $record['keywords'] ?><br/>
Description: <?php echo $record['description'] ?><br/>
Record Number: <?php echo $record['num'] ?><br/>
Posted: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['posted'])) ?><br/>
<!-- For date formatting codes see:
http://www.php.net/date -->
summary: <?php echo $record['summary'] ?><br/>
Title: <?php echo $record['title'] ?><br/>
Content: <?php echo $record['content'] ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>


<hr/>
<?php endforeach; ?>


<?php if (!$hpRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->


</body>
</html>



Here is what I put in the header of my page:

<title><?php echo $record['pagetitle'] ?></title>
<meta name="Description" content="<?php echo $record['description'] ?>" />
<meta name="Keywords" content="<?php echo $record['keywords'] ?>" />


Can you see what it is I am doing wrong. I appreciate your help.

Re: [thedmp] Meta Titles, keyword and description

By Donna - September 25, 2008

Hi there,

It looks like the code you're pasting in is coming from a List viewer (ie, the index page for a multi-page section), rather than the detail page. You won't be able to put this code into a list viewer because ... CMS Builder won't know which page to take the details from.

The example I gave will work on a detail page no problem, but a list page works a little differently. Generally, you would hardcode the title & meta tags for a list page.

Does that make sense? Let me know if you're still having trouble. :)
Donna

--
support@interactivetools.com

Re: [Donna] Meta Titles, keyword and description

Donna:

Maybe I'm building pages all wrong. Here's what I am doing: I have an existing site template that I am using so the new CMS flows with my old static website...

Anyway, I go into Secion Editors and create the new section (along with the new pagetitle, keyword and description fields. I save this.

I go into the CMS editor and fill in all of my fields with content and other info, then save the work. I then go into the Viewer Urls tab and create the URL for the list and details pages. Lastly, I go into the Viewer Code Generator and get the List or Detail page code and paste that into the template I created that matches my website. I go into the header and replace my old title, description and keyword code with the code you provided me and then save the page. The content displays fine, but the browser title shows that error I reported in my previous post and when I view the source, the keyword and description areas of the header show the same error.

Does this make sense? I really want this to work and I know once I get this figured out I will be fine, but it is an essential part of my website to have this meta info in the header.

Thanks

Dave

Re: [sagentic] Meta Titles, keyword and description

Thanks, Kenny, that did the trick.