Next, you need the code at the top of search.php to redirect to the appropriate category search if a category is selected. This is the code you need to add:
if ($_GET["category"])
{
$url = $config_baseHREF."search.php?q=category:".$_GET["category"].":".$_GET["q"];
header("Location: ".$url);
exit();
}
Put that code right at the very top; after the PHP tags.
Hello Miko,
Some users do this, it is quite easy to write.
Firstly, you need a new search form with the drop down box of categories. This file is html/searchform.php:
<div class='searchform'>
<form name='search' action='<?php print $config_baseHREF ?>search.php'>
<input type='text' name='q' size='35' value='<?php print (isset($q)?$q:""); ?>' />
<?php
print "<select name='category'>";
print "<option value=''>All Categories</option>";
$sql = "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` ORDER BY category";
if (database_querySelect($sql,$rows))
{
foreach($rows as $row)
{
$selected = "";
if (($parts[0] == "category") && ($parts[1]==$row["category"])) $selected = "selected='selected'";
print "<option value='".$row["category"]."' ".$selected.">".$row["category"]."</option>";
}
}
print "</select>";
?>
<input type='submit' value='<?php print translate("Search"); ?>' />
</form>
</div>
Next, you need the code at the top of search.php to redirect to the appropriate category search if a category is selected. This is the code you need to add:
if ($_GET["category"])
{
$url = $config_baseHREF."search.php?q=category:".$_GET["category"].":".$_GET["q"];
header("Location: ".$url);
exit();
}
Put that code right at the very top; after the PHP tags.
Hope this helps!
Cheers,
David.