Hello,
is it possible to change the title for the merchant urls from (example)
merchant:"name of merchant"
to
"Products for merchant "name of merchant"?
Thank you in advance
Perfect, thanks.
And to make the same change in the search.php result page, when it says "search results for merchant:XXX ... relevance..."
? Thank you in advance
Hi,
That is set by this code on line 118:
$banner["h2"] = translate("Product search results for")." <strong>".htmlentities($q,ENT_QUOTES,$config_charset)."</strong> ";
...so for a different version for merchant:
if ($parts[0]=="merchant")
{
$banner["h2"] = translate("Product search results for merchant ")." <strong>".$parts[1]."</strong> ";
}
else
{
$banner["h2"] = translate("Product search results for")." <strong>".htmlentities($q,ENT_QUOTES,$config_charset)."</strong> ";
}
Cheers,
David.
Thank, work fine.
Another similar question: to make the same change for "brand" page?
Hi,
To extend this mod to other search operators it would be best to replace the above modification with a switch statement; for example:
switch($parts[0])
{
case "merchant":
$banner["h2"] = translate("Product search results for merchant ")." <strong>".$parts[1]."</strong> ";
break;
case "category":
$banner["h2"] = translate("Product search results for category ")." <strong>".$parts[1]."</strong> ";
break;
case "brand":
$banner["h2"] = translate("Product search results for brand ")." <strong>".$parts[1]."</strong> ";
break;
default:
$banner["h2"] = translate("Product search results for")." <strong>".htmlentities($q,ENT_QUOTES,$config_charset)."</strong> ";
break;
}
I've added the category case in addition to brand in the above...
Hope this helps!
Cheers,
David.
Thank you David for support.
I see that in site/category/name-of-product.html the title is "category:name fo product". To modify this (I like to translate the "category" in my language) the file is the same?
Hi,
That page is generated by search.php and the title is set to the query; so to change this, look for the following around line 154:
$header["title"] = htmlentities($q,ENT_QUOTES,$config_charset);
...and REPLACE this with:
$header["title"] = htmlentities($q,ENT_QUOTES,$config_charset);
$header["title"] = str_replace("category",translate("category"),$header["title"]);
...and then it will use your translation for "category" from the translation file.
Hope this helps!
Cheers,
David.
Thank David for all suggestion.
I'm quite confused: I made all modifications, but in
site.ext/brand/CASIO/ for example,
the title is "brand:casio", but I prefer something like "Products for brand casio". Need another modification or I did not put the right code?
Thank again
Hi,
If you could perhaps email me your modified search.php and also html/header.php i'll check it all out for you...!
Cheers,
David.
Hello David
I see in Google Webmaster Tool that there is a duplicate title problem. I mean the same title "name of product bla bla" for all pages of a category
/pt/category/nameofproduct/1.html
/pt/category/nameofproduct/2.html
/pt/category/nameofproduct/3.html
Is possible to add "page 1", "page 2", etc?
Thank you again
I was forgotten. Same duplicate problem with searches like theese
/search.php?q=Battery+SGH+e330n&page=1&sort=priceAsc
/search.php?q=Battey+SGH+e330n&page=1&sort=priceDesc
/search.php?q=Battey+SGH+e330n&page=1&sort=rating
etc. How to solve this? With canonical tag declaration in the header?
Hi,
So sorry I missed your post - yes this can be done. In your search.php you'll find where the title is set by this code around about line 154:
$header["title"] = htmlentities($q,ENT_QUOTES,$config_charset);
So to add page (if > 1), and the sort order (if not default), REPLACE the above code with:
$header["title"] = htmlentities($q,ENT_QUOTES,$config_charset);
if ($_GET["page"]) $header["title"] .= " | Page ".htmlentities($_GET["page"],ENT_QUOTES,$config_charset);
if ($_GET["sort"]) $header["title"] .= " | ".htmlentities($_GET["sort"],ENT_QUOTES,$config_charset);
Hope this helps!
Cheers,
David.
Thanks David,
afther changes I received this error:
Parse error: syntax error, unexpected T_IF in /../search.php on line 356
I forgotten to say that I have this structure, sorry:
switch($parts[0])
{
case "merchant":
$header["title"] = "Products ".$parts[1];
break;
case "category":
$header["title"] = "Category ".$parts[1];
break;
case "brand":
$header["title"] = "Brand ".$parts[1];
break;
default:
$header["title"] = htmlentities($q,ENT_QUOTES,$config_charset);
}
Is possible to put the "page" in all cases?
Hi,
Sorry about that - i'd missed a ; out of the code. Sure - it can be applied to all cases - simply add the following 2 lines immediately after that block that you posted:
if ($_GET["page"]) $header["title"] .= " | Page ".htmlentities($_GET["page"],ENT_QUOTES,$config_charset);
if ($_GET["sort"]) $header["title"] .= " | ".htmlentities($_GET["sort"],ENT_QUOTES,$config_charset);
Cheers,
David.
Works fine thanks!
And for duplicate problem the solution is the one posted at http://www.pricetapestry.com/node/2621 ?
And what about the titles in the merchant/, brand/ and categories/ index pages? How can we change it?
Hi,
In each of merchants.php, categories.php and brands.php look for the following code towards the end:
require("html/header.php");
..and REPLACE that with:
$header["title"] = "Page Title Here";
require("html/header.php");
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
David,
I can't find some of the lines listed in this thread in distribution 13/03A - are these instructions still correct?
Also, with regard to the last post - I've added the line to merchants.php, but it doesnt seem to have changed the title.
Steve.
Hi Steve,
In the 13/03A distribution, look for the following code at line 399 of search.php
$header["title"] = $q;
And REPLACE with:
if (isset($parts[1]) && $parts[1])
{
$header["title"] = "Products from ".$parts[0]." ".$parts[1];
}
else
{
$header["title"] = $q;
}
This will result in a generic "Products from [index] [name]" title for each of the merchant, category or brand index search results.
Modification from the last post is still valid - prior to require("html/header.php"); you should be able to set $header["title"] = "Page Title"; for example in merchants.php look for the following code at line 36:
require("html/header.php");
...and REPLACE with;
$header["title"] = "Merchant A-Z";
require("html/header.php");
Further, you can also set arbitrary meta tags, as follows:
$header["title"] = "Merchant A-Z";
$header["meta"]["description"] = "Meta description here";
$header["meta"]["keywords"] = "meta, keywords, here";
require("html/header.php");
It looks like your template is using $header["title"] as expected (i've checked a couple of your search result and product pages) so if the above is still not working as expected email me your modified merchants.php and I'll double check for you...
Cheers,
David.
--
PriceTapestry.com
As always, your coding is spot on. Works perfectly.
I was putting $header in the wrong place (just before footer.php, not header.php). I should pay closer attention when editing!!!
Thanks again :-)
Steve.
Hi,
Sure - the title is set by the following code on line 154 of search.php:
$header["title"] = htmlentities($q,ENT_QUOTES,$config_charset);
...so to set a special title for merchant results, REPLACE the above code with:
if ($parts[0]=="merchant")
{
$header["title"] = "Products from merchant ".$parts[1];
}
else
{
$header["title"] = htmlentities($q,ENT_QUOTES,$config_charset);
}
Cheers,
David.