This was just a quick hack to get a result I needed for a product display page. It's messy and I'm sure someone will tidy it up and make it nice, but someone may be trying to do the same thing.
I have a selection of DVDs organised by studio using the manufacturer feature of X-Cart 4.0.15. Then my categories include things such as "comedy", "action", "thriller", etc. On the product display page I want a clickable graphic representation of the categories each DVD is in (comedy thriller, for example). So I put this quick botch in to product.php:
Code:
$cat_result = db_query(" SELECT xcart_products_categories.categoryid,xcart_categories.category FROM xcart_products_categories, xcart_categories WHERE xcart_products_categories.productid = $productid AND xcart_categories.categoryid = xcart_products_categories.categoryid");
while ($category = db_fetch_row($cat_result)) {
if ($category) { $product_categories[] = $category; }
}
$smarty->assign("product_categories",$product_categories);
In product.tpl I can now loop through $product_categories and use {$product_categories[loop].0} for each category id and {$product_categories[loop].1} for each category name. Or, in the case I'll be using it, .0 to provide an icon and href and .1 for the alt text.
Hope that helps someone. Sorry it's so messy; I should probably use the correct variables for table/column names but .... YMMV.
James.