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
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> ";
...and REPLACE with:
$title_q = str_replace(array("merchant:","category:","brand:"),"",$q);
$banner["h2"] = translate("Product search results for")." <strong>".htmlspecialchars($title_q)."</strong> ";
...and then the following code at line 399:
$header["title"] = $q;
...and REPLACE with:
$header["title"] = $title_q;
Cheers!
David.
--
PriceTapestry.com
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
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");
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
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 €' />
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
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?
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
I have
$header["meta"]["description"] = translate("Price search results for")." ".$product["products"][0]["name"] ".$product["products"][0]["customfieldname"] ;
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
Thanks for the quick replay (as always) it's working fine now
How can I limit the number of characters when using the product description?
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.)
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
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