Hi,
Is it possible to create a page and, only show the first x results of a specific category?
Ex: Page category-dvd.php would show the results of the "dvd" cat.
Thanks
Piki
Hi David,
It's not exactly what I want.
Here is an example: http://thebiggolfstore.com/golf-clubs.html
This guy has created serveral pages in HTMl to group it's categories.
--> That I can do.
BUT:
Under each page created, I would like to show some results of a particular category.
Thanks,
Piki
Hi Piki,
That's more straight forward. You can copy the basic category search code from search.php and incorporate it, with a fixed query, into your .html pages, and then use the searchresults.php HTML module to display the results. Here's a complete example that includes the header and footer include files, but if you already have this code in your HTML pages then just add the code between BEGIN MOD and END MOD, changing the value of $category, and the LIMIT 5 as required for more or less results...
<?php
require("includes/common.php");
require("html/header.php");
// BEGIN MOD
$category = "Widgets";
$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE category='".$category."' GROUP BY name LIMIT 5";
$searchresults["numRows"] = database_querySelect($sql,$rows);
$searchresults["products"] = $rows;
if ($searchresults["numRows"])
{
foreach($searchresults["products"] as $k => $product)
{
if ($config_useRewrite)
{
$searchresults["products"][$k]["productHREF"] = "product/".tapestry_hyphenate($product["name"]).".html";
if ($rewrite) $searchresults["products"][$k]["productHREF"] = "../../".$searchresults["products"][$k]["productHREF"];
}
else
{
$searchresults["products"][$k]["productHREF"] = "products.php?q=".urlencode($product["name"]);
}
}
require("html/searchresults.php");
}
// END MOD
require("html/footer.php");
?>
Hope this helps,
Cheers,
David.
David ... Thank you!
You're the best! It works great! Really Great!
Piki
Hi Piki,
Are you looking to have a different layout to the normal search results? Assuming that you are using $config_useRewrite, you already have an optimised link to every category in the form of:
http://www.yoursite.com/category/dvd/
...the first page of which shows the first 10 (by default) products. Are you basically looking for less than 10 results and no links to subsequent pages etc., or will these links do what you want?
Cheers,
David.