Hi,
Thank you for a great patch! What is the easiest way to insert code to limit the number of items that will show on each category page? We have hundreds of products, so I would like a random, limited number of items displayed (maybe 10).
I tried adding an array_rand() in the function -see below, but it did not work. What would be the correct way to do it?
function untreeCat($kat, &$container) {
$db = new ps_DB;
$q = "SELECT category_child_id FROM #__{vm}_category_xref WHERE category_parent_id='$kat'";
$db->query($q);
// if it is a leaf (no data underneath it) then return
if (!$db->num_rows()) {
return;
}
//else append the result, and recurse the function (so to speak)
else
{
//added this line - not working!
$db = array_rand($db, 10);
while($db->next_record()) {
$container[] = $db->f("category_child_id");
$kat = $db->f("category_child_id");
$this->untreeCat($kat, $container);
}
}
}
}
MODIFIED: I just studied shop_brows_queries.php and see that the functions is really just creating a SELECT statement for the child category ids, is this correct? In light of that, is there any way for me to limit the display to 10 random products (from these categories and sub categories)?
BTW Your Code works great! I did have to look twice at where I placed the code in ps_product_category.php as I did not understand at first that it has to go within the class vm_ps_product_category extends vmAbstractObject { }
Thank You!