News:

Looking for documentation? Take a look on our wiki

Main Menu

Auto meta description for VM2 products

Started by Ihateit, February 20, 2013, 11:15:58 AM

Previous topic - Next topic

Ihateit

Hey guise,

i'm looking for a working hack, method or plugin that automatically generates meta descriptions, keywords, etc. for my VirtueMart 2 products. If its multilingual that will be even better. I've found some, but they seem to be outdated and not work with VM2, eg. this one: http://extensions.virtuemart.net/index.php?option=com_sobi2&sobi2Task=sobi2Details&sobi2Id=328&Itemid=

Any help at all is appreciated.
Yours sincerely
Anders J.


Ihateit

#2
Quote from: mromrell on February 20, 2013, 14:56:01 PM
Try this: http://forum.virtuemart.net/index.php?topic=102251.0
Thanks Mromrell.
I've decided to go with the core hack:
if ($product->metadesc) {
    $document->setDescription($product->metadesc);
} else {
$document->setDescription("Buy ".$category->category_name." | ".$this->product->mf_name." | ".$product->product_name." | ".$product->product_desc);
}

But i want to strip HTML from the product description, as i use tables and much more. I've found this HTML stripping code, but i dont know what i should add it to, and how. Do you have any suggestion?
$clear = trim(preg_replace('/ +/', ' ', preg_replace('/[A-Za-z0-9 ]/', '', urldecode(html_entity_decode(strip_tags($des))))));
I would also like to limit the amount of characters, as my product descriptions are pretty long. :-)

I haven't quite understood the "$product->product_desc". Is it like an array where it calls the description from the product?

be

Hi,
I know that the post is some days ago but sometimes it will help.
First for stripping html or php is using strip_tags().
I do it in this way:

$desc = $product->product_desc;
$clearDesc = strip_tags($desc);

if ($product->metadesc) {
    $document->setDescription($product->metadesc);
} else {
$document->setDescription($clearDesc);
}


BR