
Originally Posted by
KismetDesign
I'm having a heck of a time trying to figure out how to show a thumbnail image of the books we're selling in the Upcoming Products list that shows up in each category.
Is there a contribution that would allow for more customization of this?
KismetDesign
Place this upcoming_products.php in includes/modules/YOUR_templatename/
PHP Code:
<?php
/**
* upcoming_products module
*
* @package modules
* @copyright Copyright 2003-2007 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: upcoming_products.php 6424 2007-05-31 05:59:21Z ajeh $
*/
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
// initialize vars
$categories_products_id_list = '';
$list_of_products = '';
$expected_query = '';
$display_limit = zen_get_upcoming_date_range();
$limit_clause = " order by " . EXPECTED_PRODUCTS_FIELD . " " . EXPECTED_PRODUCTS_SORT . "
limit " . MAX_DISPLAY_UPCOMING_PRODUCTS;
if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) {
$expected_query = "select p.products_id, pd.products_name, p.products_image, products_date_available as date_expected, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and p.products_status = 1
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'" .
$display_limit .
$limit_clause;
} else {
// get all products and cPaths in this subcat tree
$productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);
if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
// build products-list string to insert into SQL query
foreach($productsInCategory as $key => $value) {
$list_of_products .= $key . ', ';
}
$list_of_products = substr($list_of_products, 0, -2); // remove trailing comma
$expected_query = "select p.products_id, pd.products_name, p.products_image, products_date_available as date_expected, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and p.products_id in (" . $list_of_products . ")
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
$display_limit .
$limit_clause;
}
}
if ($expected_query != '') $expected = $db->Execute($expected_query);
if ($expected_query != '' && $expected->RecordCount() > 0) {
while (!$expected->EOF) {
if (!isset($productsInCategory[$expected->fields['products_id']])) $productsInCategory[$expected->fields['products_id']] = zen_get_generated_category_path_rev($expected->fields['master_categories_id']);
$expectedItems[] = $expected->fields;
$expected->MoveNext();
}
require($template->get_template_dir('tpl_modules_upcoming_products.php', DIR_WS_TEMPLATE, $current_page_base,'templates'). '/' . 'tpl_modules_upcoming_products.php');
}
?>
Then place this tpl_modules_upcoming_products.php in includes/tmplates/YourTemplate/templates
PHP Code:
<?php
/**
* Module Template
*
* @package templateSystem
* @copyright Copyright 2003-2007 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_modules_upcoming_products.php 6422 2007-05-31 00:51:40Z ajeh $
*/
?>
<!-- bof: upcoming_products -->
<fieldset>
<legend><?php echo TABLE_HEADING_UPCOMING_PRODUCTS; ?></legend>
<table border="0" width="100%" cellspacing="0" cellpadding="2" id="upcomingProductsTable" summary="<?php echo SUMMARY_TABLE_UPCOMING_PRODUCTS; ?>">
<caption><?php echo CAPTION_UPCOMING_PRODUCTS; ?></caption>
<tr>
<th scope="col" id="upProductsHeading"><?php echo TABLE_HEADING_PRODUCTS; ?></th>
<th scope="col" id="upDateHeading"><?php echo TABLE_HEADING_DATE_EXPECTED; ?></th>
</tr>
<?php
for($i=0, $row=0; $i < sizeof($expectedItems); $i++, $row++) {
$rowClass = (($row / 2) == floor($row / 2)) ? "rowEven" : "rowOdd";
echo ' <tr class="' . $rowClass . '">' . "\n";
echo ' <td >' . zen_image(DIR_WS_IMAGES . $expectedItems[$i]['products_image'], $expectedItems[$i]['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</td><td><a href="' . zen_href_link(zen_get_info_page($expectedItems[$i]['products_id']), 'cPath=' . $productsInCategory[$expectedItems[$i]['products_id']] . '&products_id=' . $expectedItems[$i]['products_id']) . '">' . $expectedItems[$i]['products_name'] . '</a></td>' . "\n";
echo ' <td align="right" >' . zen_date_short($expectedItems[$i]['date_expected']) . '</td>' . "\n";
echo ' </tr>' . "\n";
}
?>
</table>
</fieldset>
<!-- eof: upcoming_products -->
The size of the image will be the same as for new products set in admin configuration/images, but if you want somthing diferent it is easy to change by using for excample
$image_width = "your choise";
$image_height = "your choise";
and change IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT, into $image_width, $image_height
Good luck
Bookmarks