Thread: Newest Products
View Single Post
  #179  
Old 07-07-2007, 08:34 AM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default Re: Newest Products

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.
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote