Here is a way to do it by cycling through the existing product and manufacturer arrays in php and avoiding adding multiple queries. You can also do it in smarty as Cherie suggests, I just find php to be easier.
in products.php:
Code:
foreach ($products as $k => $v) {
$manufac_id = $products[$k]['manufacturerid'];
foreach ($manufacturers as $key => $value) {
if ((!$manuf_this_cat[$manufac_id])&&($manufacturers[$key]['manufacturerid']==$manufac_id)) {$manuf_this_cat[$manufac_id]=$manufacturers[$key]['manufacturer'];}
}}
$smarty->assign('manuf_this_cat',$manuf_this_cat);
In subcategories.tpl
Code:
{if $manuf_this_cat}
<hr />
<ul>
{foreach from=$manuf_this_cat key=k item=v}
<li>
manufacturerid:{$k}<br />
name:{$v}<br />
link: <a href="manufacturers.php?manufacturerid={$k}">{$v}</a>
</li>
{/foreach}
</ul>
<hr />
{/if}
The most efficient way would be to modify the original query for $products to include the manufacturers name by joining the manufacturers table, then you would not have to cycle through the manufacturers array to get the name. But that query is built in kind of a complex way and is used in many places, so, at least for me, it would take some effort to do it and test it.
---
---