Quote:
Originally Posted by LisaB
When you arrive at the link, the following error occurs when a time frame is chosen with no new products,
Warning: array_slice() [ function.array-slice]: The first argument should be an array in /home/wwwjust/public_html/shop/newproducts.php on line 153
Line 153 reads: $newproducts = array_slice($temp_products, $lowerLimit, ($upperLimit - $lowerLimit));
|
Yes, this seems to be a problem when there is no new products in the specified time period. The rest seems to be working ok. From the error message, it appears that there should be an array and none is created if the array is empty (no new products). I tried changing the area around line 147 so it says...
# if we have items to show.. go get them.. if not it will default to empty string "".
if ($total_items > 0) {
# get the product list that is limited to the page we need to display.
print_debug("temp_products count: " . count($temp_products) . "<br />");
print_debug("lowerLimit: $lowerLimit upperLimit: $upperLimit <br>");
}
if ($temp_products > 0) {
$newproducts = array_slice($temp_products, $lowerLimit, ($upperLimit - $lowerLimit));
print_debug("newproducts count: " . count($newproducts) . "<br />");
}
I added a check that $temp_products > 0.
and it seems to work. Try it and see what you get.