You are here:  » meta description

Active Forum Topics


meta description

Submitted by george-p on Fri, 2013-05-03 15:08 in

Hello David

i want to add product description as meta description

at products.php a changed

$header["meta"]["description"] = translate("Price search results for")." ".$q;
with
$header["meta"]["description"] = $product["products"][0]["description"];

but if product description has quotes , meta description is not right , like this

how i can add double quotes to meta description or another way to show description as meta description?

also how can i remove the words "brand:", "category:", "merchant:" from here http://i.imgur.com/SiL1fTB.png and meta title ?

thanks

Submitted by support on Fri, 2013-05-03 15:38

Hi George,

Use htmlspecialchars() in your modification, e.g.

  $header["meta"]["description"] = htmlspecialchars($product["products"][0]["description"]);

That should be all it is!

Cheers,
David.
--
PriceTapestry.com

Submitted by support on Fri, 2013-05-03 17:31

Sorry George, missed the second part of your question.

To remove merchant:, category: and brand: from the version of the query used in the banner and as the meta title, edit search.php and look for the following code at line 308:

$banner["h2"] = translate("Product search results for")." <strong>".htmlspecialchars($q)."</strong>&nbsp;";

...and REPLACE with:

$title_q = str_replace(array("merchant:","category:","brand:"),"",$q);
$banner["h2"] = translate("Product search results for")." <strong>".htmlspecialchars($title_q)."</strong>&nbsp;";

...and then the following code at line 399:

  $header["title"] = $q;

...and REPLACE with:

  $header["title"] = $title_q;

Cheers!
David.
--
PriceTapestry.com

Submitted by george-p on Wed, 2013-05-08 09:15

Hello David

i tried $header["meta"]["description"] = htmlspecialchars($product["products"][0]["description"]); but is the same with $header["meta"]["description"] = $product["products"][0]["description"];
still quotes at description

also how i can remove : {link saved}

thanks

Submitted by george-p on Wed, 2013-05-08 09:25

also at search i added this for description
$header["meta"]["description"] = $title_q ." ". translate("Search Results");

how i can different meta description for mechants,categories and brands?

like
for categories
$header["meta"]["description"] = $title_q ." ". translate("Category Results");

for brands
$header["meta"]["description"] = $title_q ." ". translate("Brands Results");

for merchants
$header["meta"]["description"] = $title_q ." ". translate("Merchants Results");

Submitted by support on Wed, 2013-05-08 09:40

Hello George,

Ah sorry about that - to remove quotes, rather than htmlspecialchars() use htmlentities instead; for example:

$header["meta"]["description"] = htmlentities($product["products"][0]["description"],ENT_QUOTES,$config_charset);

To remove the trailing ":", in place of the following code from the above modification:

  $title_q = str_replace(array("merchant:","category:","brand:"),"",$q);

...use:

  $title_q = str_replace(array("merchant","category","brand",":"),"",$q);

For your search results meta description; have a go with something like this:

$header["meta"]["description"] = $title_q;
switch($parts[0])
{
  case "merchant":
    $header["meta"]["description"] .= " Merchant Results";
    break;
  case "category":
    $header["meta"]["description"] .= " Category Results";
    break;
  case "brand":
    $header["meta"]["description"] .= " Brand Results";
    break;
  default:
    $header["meta"]["description"] .= " Search Results";
    break;
}

Cheers,
David.
--
PriceTapestry.com

Submitted by george-p on Wed, 2013-05-08 10:03

perfect :)

thanks

Submitted by george-p on Wed, 2013-05-08 11:15

also something else i forgot

how i can add at prodcut meta description , description and price

for example

<meta name='description' content='55DSL 1055 T Shirt By Giorgio Di Salvo Limited Edition 50 €' />

Submitted by support on Wed, 2013-05-08 11:38

Hi George,

To add price, have a go with:

$header["meta"]["description"] = htmlentities($product["products"][0]["description"],ENT_QUOTES,$config_charset)." ".$config_currencyHTML.$product["products"][0]["price"];

Cheers,
David.
--
PriceTapestry.com

Submitted by george-p on Wed, 2013-05-08 20:57

thanks

Submitted by Alex on Wed, 2018-07-18 07:58

I would like to use a custom field in the meta fields. Editing "name" or "merchant" to the fieldname didn't do to trick.

Can this be done?

Submitted by support on Wed, 2018-07-18 08:25

Hello Alex,

Custom fields should work fine in this way in products.php. Please can you post the code you added / modified and couple of lines either side of the modification so that I can see it in context and I'll check it out for you...

Cheers,
David.
--
PriceTapestry.com

Submitted by Alex on Thu, 2018-07-19 05:59

I have

$header["meta"]["description"] = translate("Price search results for")." ".$product["products"][0]["name"] ".$product["products"][0]["customfieldname"] ;

Submitted by support on Thu, 2018-07-19 06:53

Hi Alex,

As above would cause a syntax error but that may have been a copy / paste issue; have a go with;

$header["meta"]["description"] = translate("Price search results for")." ".$product["products"][0]["name"]." ".$product["products"][0]["customfieldname"];

Cheers,
David.
--
PriceTapestry.com

Submitted by Alex on Thu, 2018-07-19 08:58

Thanks for the quick replay (as always) it's working fine now

Submitted by Retro135 on Sun, 2018-08-05 07:39

How can I limit the number of characters when using the product description?

Submitted by Retro135 on Sun, 2018-08-05 20:09

In the translate section, is there a way to insert random short copy? Will this delay page load? (If so, please don't bother to post code.)

Submitted by support on Mon, 2018-08-06 07:04

Hi,

To limit the length of description used, where you would insert:

$product["products"][0]["name"]

...use this with the tapestry_substr() function which breaks on the next space following the length provided e.g;

tapestry_substr($product["products"][0]["name"],150)

Random changing text is no problem, create an array $randomtext containing the strings you want to select from, and then use within the description using array_rand() e.g.;

$randomtext = array("Random text 1","Random text 2","Random text 3");
$header["meta"]["description"] = $randomtext[array_rand($randomtext)]." ".$product["products"][0]["name"];

Cheers,
David.
--
PriceTapestry.com