I changed the main display code a bit so that it only displays each section if you have something in that section. (It's not good marketing when your first 2 sections say you have 0 products on sale and 0 this month.)
Here's the code for index.onsale.php (I changed all the other section's code in a same way).
<?php
if (!defined("CPCOMMERCE_LOADED"))
{
die("You are not allowed to access this script.");
}
// Query the Database for Products On Sale
if ($config['pageProducts'] <= 0) {
$config['pageProducts'] = 15;
$cibfug['showProducts'] = 3;
}
if ($_SESSION['cpLevel'] == 3)
$sql['onsale'] = "select distinct(A.name), A.subproducts, IF (MIN(B.stock) <> 0, IF " .
"(MIN(B.stock) < 0, 1000, MIN(B.stock)), IF (MAX(B.stock) <> 0, MAX(B.stock), " .
"IF (A.stock = -1, 1000, A.stock))) as `stock`, A.id_product, A.thumbnail, " .
"IF (MIN(B.price) <> 0, MIN(B.price), A.price) as `original_price`, D.price " .
"from `" . $db_chooser->Products() . "` as A left join " .
"`" . $db_chooser->SubProducts() . "` as B on (A.id_product=B.id_product) left " .
"join `" . $db_chooser->Categories() . "` as C " .
"on (A.id_category=C.id_category) left join `" . $db_chooser->Sales() . "` as D " .
"on (A.id_product=D.id_product) where D.start <= NOW() and D.last >= NOW() " .
"GROUP BY A.name limit 0, {$config['pageProducts']}";
else
$sql['onsale'] = "select distinct(A.name), A.subproducts, IF (MIN(B.stock) <> 0, IF " .
"(MIN(B.stock) < 0, 1000, MIN(B.stock)), IF (MAX(B.stock) <> 0, MAX(B.stock), " .
"IF (A.stock = -1, 1000, A.stock))) as `stock`, A.id_product, A.thumbnail, " .
"IF (MIN(B.price) <> 0, MIN(B.price), A.price) as `original_price`, F.price " .
"from `" . $db_chooser->Products() . "` as A left join " .
"`" . $db_chooser->SubProducts() . "` as B on " .
"(A.id_product=B.id_product) left join `" . $db_chooser->LinkedProducts() . "` as " .
"D on (A.id_product=D.id_product) left join `" . $db_chooser->Categories() . "` as " .
"C on (A.id_category=C.id_category or D.id_category=C.id_category) left join " .
"`" . $db_chooser->Sales() . "` as F on (A.id_product=F.id_product) where F.start " .
"<= NOW() and F.last >= NOW() and C.visible='1' GROUP BY A.name limit 0, " .
"{$config['pageProducts']}";
$query['onsale'] = $db_chooser->sql_query($sql['onsale']) or die($db_chooser->sql_error());
if ($query['onsale'] && $db_chooser->sql_num_rows($query['onsale'])) {
$count = 1;}
else return 0;
?>
<table class="tblContentModule" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="tdContentTitle">
<?php echo $output['0251']; ?>
</td>
</tr>
<tr>
<td class="tdContentText">
<table id="tblOnSale" border="0" cellpadding="0" cellspacing="0">
<?php
// Check that the Query is valid and it returns information
if ($query['onsale'] && $db_chooser->sql_num_rows($query['onsale'])) {
// Cycle through the Return Information
$count = 1;
while ($info['onsale'] = $db_chooser->sql_fetch_assoc($query['onsale'])) {
// Show the Opening Table Row
if (($count - 1) % $config['showProducts'] == 0)
echo "<tr>";
// Output the Cell Header
echo "<td class=\"tdOnSaleProduct\">";
// Output the Uplaoded Image
if (trim($info['onsale']['thumbnail']) != "" &&
file_exists("{$config['productsthumbnail']}{$info['onsale']['thumbnail']}")) {
// Get the Width and Height of the Image
$dimensions = getimagesize("{$config['productsthumbnail']}{$info['onsale']['thumbnail']}");
// Output
echo "<center><a href=\"product.php?id_product={$info['onsale']['id_product']}\"><img " .
"src=\"{$config['productsthumbnail']}{$info['onsale']['thumbnail']}\" " .
"width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\" border=\"0\" " .
"alt=\"{$info['onsale']['name']}\" /></a></center>";
// Output the Default Image
} else {
// Get the Width and Height of the Image
$dimensions = getimagesize("{$config['productsthumbnail']}blank.gif");
// Output
echo "<center><a href=\"product.php?id_product={$info['onsale']['id_product']}\"><img " .
"src=\"{$config['productsthumbnail']}blank.gif\" width=\"{$dimensions[0]}\" " .
"height=\"{$dimensions[1]}\" border=\"0\" alt=\"{$info['onsale']['name']}\" " .
"/></a></center>";
}
// Output the Name of the Product
echo "<center><a href=\"product.php?id_product={$info['onsale']['id_product']}\">" .
"{$info['onsale']['name']}</a></center>";
// Query the Database to see if the SubProducts are all out of Stock
$sql['subproducts'] = "select count(*) as `instock` from `" . $db_chooser->SubProducts() . "` " .
"where `id_product`={$info['onsale']['id_product']} and `stock`!=0";
$query['subproducts'] = $db_chooser->sql_query($sql['subproducts']);
// Grab the Results
$info['subproducts'] = $db_chooser->sql_fetch_assoc($query['subproducts']);
// Output the Stock Status
if ($info['onsale']['stock'] != 0)
echo "<center><span class=\"spnOnSaleProductInStock\">{$output['0092']}</span> ";
else
echo "<center><span class=\"spnOnSaleProductOutOfStock\">{$output['0093']}</span> ";
// Output the Price
echo "<span class=\"spnOnSaleProductOnSale\">" . format_currency($info['onsale']['price']) .
"</span></center></td>";
// Show the Closing Table Row
if ($count % $config['showProducts'] == 0)
echo "</tr>";
$count++;
}
// Close the Table Row Properly
if (($count - 1) % $config['showProducts'] != 0)
echo "<td colspan=\"" . ($count - (($count - 1) % $config['showProducts'])) . "\"></td></tr>";
}
?>
</table>
</td>
</tr>
</table>