You are here:  » Metatags

Support Forum



Metatags

Submitted by marco@flapper on Wed, 2011-07-27 16:20 in

Hi,
I'm trying to modify my pricetapestry metatags (description and keywords).
What I want is that it shows on the index page the in the config.php configured description and keywords. And that it shows on the product page as description the first 150 characters of the product description and as keywords the category name, the brand name and the product name as three keywords.

I succeeded in letting it use the in the config.php configured description and keywords by adding this to the header.php:

<meta name='description' content='<?php print $config_metaDescriptionIndex?>' />
<meta name='keywords' content='<?php print $config_metaKeywordsIndex?>' />

but I'm not sure how to do that for the product pages. Please note that I'm using another pricetapestry template.

I allready had this in products.php:

$header["meta"]["description"] = translate("Price search results for")." ".htmlentities($q,ENT_QUOTES,$config_charset);
      $header["meta"]["keywords"] = htmlentities($q,ENT_QUOTES,$config_charset);

So now I have on the product pages two meta description and two meta keyword tags.

Could you help me with this?

Submitted by support on Wed, 2011-07-27 18:25

Hi Marco,

Rather than edit html/header.php directly, it's best to set the $header["meta"] array accordingly, before the call to require("html/header.php");

If you first undo the changes to html/header.php, the next step is look for this code at line 4 of index.php

  require("html/header.php");

...and REPLACE with:

  $header["meta"]["description"] = $config_metaDescriptionIndex;
  $header["meta"]["keywords"] = $config_metaKeywordsIndex;
  require("html/header.php");

For the product page, in products.php, replace the code that you have already identified with the following, to give 150 characters (to the nearest space) of the description as the meta description, and the category, brand and product name as the 3 keywords:

  $header["meta"]["description"] = tapestry_substr($product["products"][0]["description"],150);
  $keywords = array();
  if ($product["products"][0]["category"]) $keywords[] = $product["products"][0]["category"];
  if ($product["products"][0]["brand"]) $keywords[] = $product["products"][0]["brand"];
  $keywords[] = $product["products"][0]["name"];
  $keywords = implode(",",$keywords);
  $header["meta"]["keywords"] = htmlentities($keywords,ENT_QUOTES,$config_charset);

The above will make sure that there are no spurious commas for example, where a product isn't associated with a brand...!

Cheers,
David.
--
PriceTapestry.com

Submitted by marco@flapper on Thu, 2011-07-28 11:51

Thanks David,
it works exactly like I wanted it.