Hi David,
Firstly congrats on such a great product. It's so customisable - i'm using it to build on niche sections in an already large price comparison website - kudos!
Secondly, i've a bit of an issue. I followed your tutorial to turn ampersand filled urls into nice static ones.
At the moment when I do a search, the url looks like /search/relevance/blackberry/ which works fine.
I do, however, want to create links to certain keywords AND categories like /search/relevance/blackberry:category:prepay-mobile-phones/
In the string above, 'blackberry' is the keyword, and the category name is 'Prepay Mobile Phones'.
However, the query above is showing results from other categories also - what do you recommend the format be for such a query?
Thanks again for such a great product!
Thanks for your reply to this - it's in your mailbox as we speak ;-)
Is it possible to provide the changes made so others can follow? I feel that people don't learn things unless they get to do it themselves through time and testing :)
If you can give me a pointer. It would be appreciated. I was going to do htaccess rewrites but it would be time consuming, being able to use categories would be excellent.
Thanks
Steve
Hi Steve,
Sure - firstly, the new rule should be added to the end of .htaccess
RewriteRule ^search/(.*)/(.*)/$ search.php?q=$2&sort=$1&rewrite=1&%{QUERY_STRING} [L]
RewriteRule ^search/(.*)/(.*)/(.*).html$ search.php?q=$2&sort=$1&page=$3&rewrite=1&%{QUERY_STRING} [L]
Next, a hidden field needs to be added to the search form to trigger the redirect. To do this, in html/searchform.php, search for the following:
</form>
...and REPLACE with:
<input type='hidden' name='redir' value='1' /></form>
Then in search.php, look for the following code at line 12:
$rewrite = isset($_GET["rewrite"]);
...and REPLACE with:
$rewrite = isset($_GET["rewrite"]);
if ($_GET["redir"])
{
$location = $config_baseHREF."search/".$sort."/".tapestry_hyphenate($q)."/";
header("Location: ".$location);
exit();
}
Finally, to make sure that the change sort order links go to the rewritten version, look for the following block of code beginning at line 229:
$sortHREF = $config_baseHREF."search.php?q=".urlencode($q)."&page=1&";
if ($minPrice || $maxPrice)
{
$sortHREF .= "minPrice=".$minPrice."&maxPrice=".$maxPrice."&";
}
$sortHREF .= "sort=";
$sortRelevance = ($sort=="relevance"?"<strong>".translate("Relevance")."</strong>":"<a href='".$sortHREF."relevance'>".translate("Relevance")."</a>");
if ($config_useInteraction)
{
$sortRating = ", ".($sort=="rating"?"<strong>".translate("Product Rating")."</strong>":"<a href='".$sortHREF."rating'>".translate("Product Rating")."</a>");
}
else
{
$sortRating = "";
}
$sortPriceAsc = ($sort=="priceAsc"?"<strong>".translate("Low to High")."</strong>":"<a href='".$sortHREF."priceAsc'>".translate("Low to High")."</a>");
$sortPriceDesc = ($sort=="priceDesc"?"<strong>".translate("High to Low")."</strong>":"<a href='".$sortHREF."priceDesc'>".translate("High to Low")."</a>");
...and REPLACE with:
if ($rewrite)
{
$sortHREF = $config_baseHREF."search/%SORT%/".urlencode($q)."/";
$sortRelevance = ($sort=="relevance"?"<strong>".translate("Relevance")."</strong>":"<a href='".str_replace("%SORT%","relevance",$sortHREF)."'>".translate("Relevance")."</a>");
if ($config_useInteraction)
{
$sortRating = ", ".($sort=="rating"?"<strong>".translate("Product Rating")."</strong>":"<a href='".str_replace("%SORT%","rating",$sortHREF)."'>".translate("Product Rating")."</a>");
}
else
{
$sortRating = "";
}
$sortPriceAsc = ($sort=="priceAsc"?"<strong>".translate("Low to High")."</strong>":"<a href='".str_replace("%SORT%","priceAsc",$sortHREF)."'>".translate("Low to High")."</a>");
$sortPriceDesc = ($sort=="priceDesc"?"<strong>".translate("High to Low")."</strong>":"<a href='".str_replace("%SORT%","priceDesc",$sortHREF)."'>".translate("High to Low")."</a>");
}
else
{
$sortHREF = $config_baseHREF."search.php?q=".urlencode($q)."&page=1&";
if ($minPrice || $maxPrice)
{
$sortHREF .= "minPrice=".$minPrice."&maxPrice=".$maxPrice."&";
}
$sortHREF .= "sort=";
$sortRelevance = ($sort=="relevance"?"<strong>".translate("Relevance")."</strong>":"<a href='".$sortHREF."relevance'>".translate("Relevance")."</a>");
if ($config_useInteraction)
{
$sortRating = ", ".($sort=="rating"?"<strong>".translate("Product Rating")."</strong>":"<a href='".$sortHREF."rating'>".translate("Product Rating")."</a>");
}
else
{
$sortRating = "";
}
$sortPriceAsc = ($sort=="priceAsc"?"<strong>".translate("Low to High")."</strong>":"<a href='".$sortHREF."priceAsc'>".translate("Low to High")."</a>");
$sortPriceDesc = ($sort=="priceDesc"?"<strong>".translate("High to Low")."</strong>":"<a href='".$sortHREF."priceDesc'>".translate("High to Low")."</a>");
}
Hope this helps!
Cheers,
David.
Hi,
Can you email me your search.php and I'll modify the merchant/category/brand search handler to support multiple fields including keywords (a search on the name field), and you will then be able to link to, for example:
/search/relevance/category:prepay-mobile-phones:name:blackberry/
Cheers,
David.