If less than 10 matching products are find then broaden the search to include other forms of the word?
How can you do this in search.php?
Hi mediadream,
What you can also try is take a copy of 'search.php' and use this as your 'noresults.php'. Amend the search strings in this new 'noresults.php' to provide a broader search and then amend the original search.php to call 'noresults.php' if $searchresults is either null or less than 10. The code required will probably depend on your version of PT so if you wanted to go this route, David would have to help here. What I have done is have my normal 'search.php' to use the full text search method - which normally provided better quality results - and then the query in my 'noresults.php' uses the non-full text search which usually provides more results. You could tailor the query to search your needs, such as searching brand or category fields.
Cheers.
Keeop
Hi mediadream,
One way you could do this is as follows; but in all cases check that the new query returns better results before entering into the $broaden array. In search,php look for the following code around line 230 (11/09A):
$resultCount = $rows[0]["resultcount"];
..and REPLACE with:
$resultCount = $rows[0]["resultcount"];
if ($resultCount < 10)
{
$broaden["keyword1"] = "alternative keywords1"
$broaden["keyword2"] = "alternative keywords2"
$broaden["keyword3"] = "alternative keywords3"
if (isset($broaden[$q]))
{
header("Location: ".$config_baseHREF."search.php?q=".urlencode($broaden[$q]));
exit();
}
}
Hope this helps!
Cheers,
David.
--
PriceTapestry.com