Greetings,
I am trying to get my categories to show on the index page, so I added this bit of code to it.
<?php
$atoz["items"] = array();
$sql = "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` ORDER BY category";
if (database_querySelect($sql,$rows))
{
foreach($rows as $product)
{
if ($product["category"])
{
$item = array();
$item["name"] = $product["category"];
if ($config_useRewrite)
{
$item["href"] = tapestry_hyphenate($product["category"])."/";
}
else
{
$item["href"] = "search.php?q=category:".urlencode($product["category"]).":";
}
$atoz["items"][] = $item;
}
}
}
require("html/atoz.php");
print "<br clear='all'>";
?>
Which looks GREAT, but the category links are linking into a different folder which is causing an error. Any ideas on how I can make this work?
Excellent, worked perfectly
Big thanks from a NON developer trying to tweak this script to make it look unique!
Ian
Hi,
It should just be a case of prefixing category/ infront of the value; so instead of:
if ($config_useRewrite)
{
$item["href"] = tapestry_hyphenate($product["category"])."/";
}
Use:
if ($config_useRewrite)
{
$item["href"] = $config_baseHREF."category/".tapestry_hyphenate($product["category"])."/";
}
That should do the trick...
Cheers,
David.