So I have a client that wants products in current category listed on the side even when on the product info page. The best way I could do this was a side box that listed all products in current category. There was nothing like this I could find so I came up with this. I noticed a few people looking for something like this so here ya go. It will list all products with image and link to product page.
in includes/modules/sideboxes create prolist.php(short for productlist) and include this code:
Then in includes/templates/YOUR_TEMPLATE/sideboxes create tpl_prolist.php and add this:Code:<?php require($template->get_template_dir('tpl_prolist.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes') . '/tpl_prolist.php'); $title = ''; $title_link = false; require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default); ?>
I am a php noob so any ideas on improvments are welcomeCode:<?php /** * Product Listing Sidebox * */ $content = ''; $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">'; $prolist_query = "select products.products_image, products_description.products_name, products_to_categories.*, categories_description.categories_id from products, products_description, products_to_categories, categories_description where categories_description.categories_id = '$current_category_id' and categories_description.categories_id = products_to_categories.categories_id and products_description.products_id = products_to_categories.products_id and products.products_id = products_description.products_id order by products_description.products_name "; $prolist = $db->Execute($prolist_query); while (!$prolist->EOF) { $content .= '<a href="' . zen_href_link(zen_get_info_page($prolist->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $prolist->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $prolist->fields['products_image'], $prolist->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT, 'class="listingProductImage"') . '</a>'; $prolist->MoveNext(); }; $content .= '</div>'; ?>![]()




