Forum Moderators: coopster

Message Too Old, No Replies

Titles and meta descriptions

Adding Title and meta description to generated pages

         

eclipsetbs

11:29 am on Nov 27, 2009 (gmt 0)

10+ Year Member



How are individual Titles and meta descriptions added dynamically to the head of dynamically generated pages (for property adverts) as opposed to the body (straightforward)? These pages are generated using php from data already stored in MySQL in this inherited 2006 website. Sections (eg Homepage) and Article pages are created in a CMS and already have this facility, but I can't work out the process used to adapt for the advert pages, to improve our SEO.

rocknbil

10:01 pm on Nov 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Where are the "adverts" stored?

You'd likely have database columns for meta descr, title, etc. for each of these elements. If you don't, you can extract the title element from the company title and description from the first couple lines of property description, stripping out any HTML.

Not optimum, but it will work.

eclipsetbs

11:49 pm on Nov 27, 2009 (gmt 0)

10+ Year Member



Thanks rocknbil - you are correct. Content for each advert is in fields of a table in the db. I have a field for AdvertTitle and one for a ShortDesc, which are ideal to adapt for what I need. However, I'm not a php coder and just need to know how to take that detail fron the db for each displayed advert and add it to the <head> part of the generated html page.

The orig developer had this in the file (for the title):

/*This was a try for Advert Title tag
function dspAdvertRevisions($rs, $AdvertID, $char) {
$aAdvertTitle = array();
$PageID = $AdvertID;
$varPageID = $PageID;
$rsAdvertRevisions = GetAdvertRevisions($aAdvertTitle, $connDB);
if ($varPageID!="") {
while (!$rsAdvertRevisions->EOF) {
if ($rsAdvertRevisions->Fields('AdvertID') == $varPageID) {
$aHTMLTitle['HTMLTitle'] = htmlspecialchars($rsAdvertRevisions->Fields('AdvertTitle')) ;
}
$rsAdvertRevisions->MoveNext();
}
}
return $aHTMLTitle;
}*/

This is how the <body> details (which I follow and edit even) are called:

function dspAdvert($arr_get) {
$AdvertInfo = array();
$AdvertRevisionInfo = array();
$AdvertInfo = get_approvedadvert_details($arr_get['adid']);
if ($AdvertInfo['AdvertID'] <> "") {
$s .= "<div id=\"rental\">\n";
$s .= "<h1><span class=\"goRight\">&nbsp;&nbsp;&nbsp;&nbsp;" . $AdvertInfo['PriceFrom'] . "</span>" . htmlspecialchars($AdvertInfo['AdvertTitle']) . "</h1>";
$s .= "<table id=\"tblAdvertDetail\" cellpadding=\"1\" cellspacing=\"2\">\n";
$s .= "<tr>\n";
$s .= "<td id=\"advert-detail\">\n";
$s .= "<div id=\"rental-details\">\n";
$s .= "<p class=\"where\">" . htmlspecialchars($AdvertInfo['AreaName']) . ", " . htmlspecialchars($AdvertInfo['Country']) . "</p>\n";
$s .= "<ul>\n";
if ($AdvertInfo['ResidenceType'] != "") {
$s .= "<li>&#8226; " . htmlspecialchars($AdvertInfo['ResidenceType']) . "</li>\n";
}
if ($AdvertInfo['LocationType'] != "") {
$s .= "<li>&#8226; " . htmlspecialchars($AdvertInfo['LocationType']) . " location</li>\n";
}
$s .= "<li>&#8226; " . htmlspecialchars($AdvertInfo['NoOfBedrooms']) . " Bedroom(s)</li>\n";
if ($AdvertInfo['Sleeps'] != "") {
$s .= "<li>&#8226; Sleeps up to " . htmlspecialchars($AdvertInfo['Sleeps']) . "</li>\n";
}
if ($AdvertInfo['FloorArea'] != "") {
$s .= "<li>&#8226; Floor area " . htmlspecialchars($AdvertInfo['FloorArea']) . " m2</li>\n";
}
if ($AdvertInfo['ChildrenWelcome'] == 1) {
$s .= "<li>&#8226; Children welcome - " . dspYesNo($AdvertInfo['ChildrenWelcome'],false) . "</li>\n";
}
if ($AdvertInfo['ElderlyOK'] == 1) {
$s .= "<li>&#8226; OK for the Elderly or Infirm</li>\n";
}
if ($AdvertInfo['DisabledAccess'] == 1) {
$s .= "<li>&#8226; Disabled Access</li>\n";
}
if ($AdvertInfo['PetsDesc'] != "") {
$s .= "<li>&#8226; " . htmlspecialchars($AdvertInfo['PetsDesc']) . "</li>\n";
}
$s .= "</ul>\n";
$s .= "</div>\n";
$s .= "<div id=\"rental-desc\">\n";
$s .= "<center><iframe name=\"I1\" id=\"I1\" src=\"http://www.mywebsite.co.uk/inserts/advert" . $AdvertInfo['AdvertID'] . ".htm\" frameborder=\"0\" width=\"560\" scrolling=\"no\" height=\"575\"></iframe></center><br />\n";
$s .= $AdvertInfo['LongDesc'] . "\n";
$s .= "</div>\n";
$s .= dspAdvertFacilities($arr_get['adid'],"");
$advertiserinfo = get_user_details($AdvertInfo['UserID']);
$s .= "<div id=\"call-to-arms\">\n";
$s .= "<center><p>PLEASE CONTACT OWNER BY <a href=\"mailto:" . $advertiserinfo['userobfusc'] . "?subject=Booking enquiry for advert " . $AdvertInfo['AdvertID'] . "&amp;cc=&#x69;&#x6e;&#x66;&#111;&#x40;&#115;&#111;&#108;&#x61;&#x70;&#97;&#x72;&#x74;&#x6d;&#x65;&#110;&#x74;&#115;&#x2e;&#99;&#111;&#x2e;&#x75;&#x6b;\">EMAIL</a>
</p><p>OR PHONE: " . $AdvertInfo['AdvertTelNo'] . "</p></center>\n";
$s .= "</div>\n";
$s .= " <br />\n";
$s .= " <p>Advert Created : " . $AdvertInfo['DateCreated'] . "</p>\n";
$s .= " <p>Details Last Updated : " . $AdvertInfo['ApprovedDate'] . "</p>\n";
$s .= " <p>(apart from the Calendar)</p>\n";
$s .= "</td>\n";
$s .= "</tr>\n";
$s .= "</table>\n";
$s .= "</div>\n";
} else {
$s .= "<h2>Error</h2>\n
<p>The Advert you have requested cannot be displayed.</p>\n";
}
return $s;
}

There is a lot of other associated code, but maybe you can get the idea where I'm coming from.

Thanks, Dave