Page 1 of 1

Need help with dynamic meta tags

Posted: Sat Jun 17, 2006 1:46 pm
by Sportsmen
Hello,

Was hoping someone could point this noobie in the right direction.
I have website that has about 20,000 products listed on it. Of course the site is dynamic
pulling information from a mysql database. I didn't build the site but was hoping as a novice programmer I could fix it.

The major search engines have started to index some of the pages on the site but thinks they are duplicates.
While each page does have a unique "title" the description is always the same, the anchor text of my menu structure, (SEARCH. All Categories. All Manufacturers. HOME · CUSTOMER SERVICE FAQ · CART ACCOUNT · REGISTER : LOGIN · SHOP NOW! RESOURCES · ABOUT US · CONTACT US) Not very helpful with 20k pages like this. I think this text is gettin read first because my description meta tag is empty for every item.


Ok, so here is the code that is in my header.php file.
<title><?= $page->fetchTitle() ?></title>
<meta NAME="description" content="<?= $page->fetchDesc() ?>" />
<meta name="keywords" content="<?= $page->fetchKey() ?>" />
This is what is returned for each page. Each title is unique but keywords and description are blank. I don't know why the fetch commands do not retrieve any information for keywords or descriptions.
<title>Unique Page Title for Each Product </title> (modified so I am not promoting my site)
<meta NAME="description" content="" />
<meta name="keywords" content="" />
Is it possible to pull the "product description" information that is loaded for each product into the "description meta tags"?. Some of the descriptions are lengthy so I would only want 20-30 words.

This is the code that is listed on the "product_detail.php" that i'm guessing is used to pull the "product description" from the database for each item.
<td class="product_detail_text" colspan="2">
<p><?= $obj_prod->get('description') ?></p>

Let me know if more information is needed and thank you in advance for any help or comments.

Posted: Sat Jun 17, 2006 3:57 pm
by aerodromoi
As a workaround you might want to use either substr to shorten your description or use a function similar to this one:

Code: Select all

function cutshort($string){
	$wordarray = explode(" ", $string);
	$numw = 6;
	$outputstring = "";
	for ($i=0;$i<$numw;$i++) $outputstring .= $wordarray[$i]." ";
	$outputstring .= "...";
	return $outputstring;
}

$string = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla diam. Mauris vulputate, lectus vitae facilisis vehicula, eros neque aliquet dolor, sed vulputate tortor libero id risus.";

echo cutshort($string);
However, both solutions are just workarounds. Keywords have to be concise - there is no point in using (cut off) sentences as a substitute.
Obviously the methods/functions don't return anything. But in order to fix that, you'd have to give us a clue as to the class itself.

aerodromoi

btw: I wouldn't use short tags - they don't exactly promote compatibility ;)
btw2: uppercase vs. lowercase "NAME" - I prefer the latter