Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!


Sponsored Content

 

 
 

Photo
- - - - -

Dynamic Meta Tag Description


  • Please log in to reply
2 replies to this topic

#1 jaybo

jaybo

    HR 2

  • Members
  • PipPip
  • 10 posts

Posted 15 June 2006 - 10:46 PM

I am currently optimizing my oscommerce webshop metatags.
In particular the metatag description.

I added this code:

CODE
<meta name="description" content="<?php echo  $meta_description_tag; ?>">

and

$meta_description = ereg_replace('<[^>]*>', '', $product_info['products_description']);
if (strlen($meta_description) > 200){
$meta_description_tag = substr($meta_description, 0, 200) . '...';
}else {
$meta_description_tag = $meta_description;
}


It works ok, except for some pages: <URL removed > if you look closely at the description you will see because of the " in the product description closes the metatag description.

how can I avoid this?

Edited by chrishirst, 16 June 2006 - 01:21 AM.


#2 chrishirst

chrishirst

    A not so moderate moderator.

  • Moderator
  • 5,884 posts
  • Location:Blackpool UK

Posted 16 June 2006 - 01:23 AM

Add " (quote marks) into the replace pattern and remove them

#3 jaybo

jaybo

    HR 2

  • Members
  • PipPip
  • 10 posts

Posted 16 June 2006 - 06:28 AM

Ok I am no expert, I copied this code out of a oscommerce contribution.

But does it need to like this?

CODE
$meta_description = ereg_replace('<[^>]*>', '', ",$product_info['products_description']);
if (strlen($meta_description) > 200){
$meta_description_tag = substr($meta_description, 0, 200) . '...';
}else {
$meta_description_tag = $meta_description;
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users