Easy enough. Add this code to the end of your includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display file:
PHP Code:
<?php
/* This code adds a products listing to the bottom of products_info pages
* containing other products in this category. It is similar to Featured
* or New Products.
*
* I use the class centerBoxContentsFeatured and id featuredProducts for
* convenience, I would recommend removing those and using the class
* centerBoxContentsThisCategory and id thisCategoryProducts is your css.
*/
// setup constants here
define('MAX_DISPLAY_SEARCH_RESULTS_THIS_CATEGORY', 9);
define('SHOW_PRODUCT_INFO_COLUMNS_THIS_CATEGORY_PRODUCTS', 3);
define('IMAGE_THIS_CATEGORY_PRODUCTS_LISTING_WIDTH', 100);
define('IMAGE_THIS_CATEGORY_PRODUCTS_LISTING_HEIGHT', 80);
define('TABLE_HEADING_THIS_CATEGORY_PRODUCTS', 'Other Products in This Category');
include(DIR_WS_MODULES . 'pages/index/header_php.php');
$products_query = "select distinct p.products_id, p.products_image, pd.products_name
from (" . TABLE_PRODUCTS . " p
left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id), " .
TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
TABLE_CATEGORIES . " c
where p.products_id = p2c.products_id
and p2c.categories_id = c.categories_id
and c.categories_id = '" . (int)$current_category_id . "'
and p.products_id != '" . (int)$_GET['products_id'] . "'
and p.products_id = pd.products_id and p.products_status = 1 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
$products_this_category = $db->ExecuteRandomMulti($products_query, MAX_DISPLAY_SEARCH_RESULTS_THIS_CATEGORY);
$row = 0;
$col = 0;
$list_box_contents = array();
$title = '';
$num_products_count = $products_this_category->RecordCount();
// show only when 1 or more
if ($num_products_count > 0) {
if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_THIS_CATEGORY_PRODUCTS) {
$col_width = floor(100/$num_products_count);
} else {
$col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_THIS_CATEGORY_PRODUCTS);
}
while (!$products_this_category->EOF) {
$products_price = zen_get_products_display_price($products_this_category->fields['products_id']);
$list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured centerBoxContentsThisCategory centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
'text' => (($products_this_category->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($products_this_category->fields['products_id']), 'products_id=' . $products_this_category->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $products_this_category->fields['products_image'], $products_this_category->fields['products_name'], IMAGE_THIS_CATEGORY_PRODUCTS_LISTING_WIDTH, IMAGE_THIS_CATEGORY_PRODUCTS_LISTING_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($products_this_category->fields['products_id']), 'products_id=' . $products_this_category->fields['products_id']) . '">' . $products_this_category->fields['products_name'] . '</a><br />' . $products_price);
$col ++;
if ($col > (SHOW_PRODUCT_INFO_COLUMNS_THIS_CATEGORY_PRODUCTS - 1)) {
$col = 0;
$row ++;
}
$products_this_category->MoveNextRandom();
}
if ($products_this_category->RecordCount() > 0) {
$title = '<h2 class="centerBoxHeading">' . TABLE_HEADING_THIS_CATEGORY_PRODUCTS . '</h2>';
$zc_show_featured = true;
}
}
?>
<!-- bof: products_this_category -->
<div class="centerBoxWrapper" id="featuredProducts thisCategoryProducts">
<?php
require($template->get_template_dir('tpl_columnar_display.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_columnar_display.php');
?>
</div>
<!-- eof: products_this_category -->
Note that this has NOT been thoroughly tested and you should test it on a testing site before employing it on a live site.
BrandTim
Bookmarks