Hi David
I am looking to add a (view this categories merchants) link to each category listed in categories.php which will show only the merchants who have products in that category in merchants.php. I think this may have been covered before, could you point me in the right direction please.
Chris
Hello Chris,
Straight forward to add - firstly in categories.php look for the following code at line 6:
$sql = "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` ORDER BY category";
...and REPLACE with:
if (isset($_GET["merchantFilter"]))
{
$sql = "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($_GET["merchantFilter"])."' ORDER BY category";
}
else
{
$sql = "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` ORDER BY category";
}
With that in place, it's just a case of linking to the category A-Z with merchantFilter set. Best place to add the links is problem in html/atoz.php - look for the following code at line 56:
print "</p>";
...and REPLACE with:
if (strpos($_SERVER["PHP_SELF"],"merchants.php"))
{
if ($config_useRewrite)
{
$href = $config_baseHREF."category/?merchantFilter=".urlencode($item["name"]);
}
else
{
$href = $config_baseHREF."categories.php?merchantFilter=".urlencode($item["name"]);
}
print "<br /><a href='".$href."'>View Cateories</a>";
}
print "</p>";
Cheers,
David.
--
PriceTapestry.com