Home | Products | Consulting | Forums | Support | Order | 1-800-752-0455
  Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Meta Titles, keyword and description

 

 


thedmp
User

Sep 25, 2008, 3:28 PM

Post #1 of 7 (778 views)
Shortcut
Meta Titles, keyword and description Can't Post

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?


Donna
Staff / Moderator


Sep 25, 2008, 3:43 PM

Post #2 of 7 (777 views)
Shortcut
Re: [thedmp] Meta Titles, keyword and description [In reply to] Can't Post

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:


Code
<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:


Code
<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


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.


(This post was edited by Donna on Sep 25, 2008, 3:43 PM)


thedmp
User

Sep 25, 2008, 5:03 PM

Post #3 of 7 (767 views)
Shortcut
Re: [Donna] Meta Titles, keyword and description [In reply to] Can't Post

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
/* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */
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 style="color: red; font-weight: bold">Rename this file to have a .php extension!</li><x */ ?>
<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.


Donna
Staff / Moderator


Sep 25, 2008, 5:10 PM

Post #4 of 7 (765 views)
Shortcut
Re: [thedmp] Meta Titles, keyword and description [In reply to] Can't Post

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


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.


thedmp
User

Sep 25, 2008, 5:33 PM

Post #5 of 7 (760 views)
Shortcut
Re: [Donna] Meta Titles, keyword and description [In reply to] Can't Post

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


sagentic
User


Sep 25, 2008, 8:30 PM

Post #6 of 7 (741 views)
Shortcut
Re: [thedmp] Meta Titles, keyword and description [In reply to] Can't Post

Make your head code look like this:


Code
<?php 
/* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */
require_once "/home/pctechby/public_html/support/lib/viewer_functions.php";


list($hpRecords, $hpMetaData) = getRecords(array(
'tableName' => 'hp',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$hpRecord = @$hpRecords[0]; // get first record


<!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>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title><?php echo $hpRecord['pagetitle'] ?></title>
<meta name="Description" content="<?php echo $hpRecord['description'] ?>" />
<meta name="Keywords" content="<?php echo $hpRecord['keywords'] ?>" />


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



Use the Detail Viewer code instead of list page code to make this work.

One of the differences (besides the top of page code) is that the echo statements define exactly what table to pull from like this:

<?php echo $hpRecord['pagetitle'] ?>

On a List Viewer page, it would look like this:

<?php foreach ($hpRecords as $record): ?>
<?php echo $record['pagetitle'] ?>
<?php endforeach; ?>


You also don't need to put all of the code that the code generator outputs such as instructions and record numbers.


Try that and see if it works for you - post back if it doesn't and we can troubleshoot further.

Kenny


thedmp
User

Sep 27, 2008, 4:56 AM

Post #7 of 7 (665 views)
Shortcut
Re: [sagentic] Meta Titles, keyword and description [In reply to] Can't Post

Thanks, Kenny, that did the trick.

 
 
 


Search for (options)
Products
CMS Builder
Article Manager
Realty Manager
Listings Manager
Order Now
Services
Priority Consulting
Support
Online Documentation
Support Forums
Support Homepage
Company Info
12 reasons to choose us!
Meet the team
Monthly newsletter
Contact Us
Toll Free: 1-800-752-0455
Phone: (604) 689-3347
Sales | Support
Conditions of Use | Privacy Policy | Copyright © interactivetools.com 2008
#201 - 2730 Commercial Drive, Vancouver BC Canada V5N 5P4