Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Display manufacturer list on category page

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #21  
Old 03-27-2012, 03:18 PM
  gb2world's Avatar 
gb2world gb2world is offline
 

X-Wizard
  
Join Date: May 2006
Location: Austin, TX
Posts: 1,970
 

Default Re: Display manufacturer list on category page

Good point - to avoid multiple queries you can go back to the original $products array and query for the manufacturer name as well as the id. But the array he is requesting is not already there. You can either add to the query in the php or cycle through the product and manufacturers arrays to get it.

---
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold
(CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module)
Reply With Quote
  #22  
Old 03-27-2012, 09:20 PM
  gb2world's Avatar 
gb2world gb2world is offline
 

X-Wizard
  
Join Date: May 2006
Location: Austin, TX
Posts: 1,970
 

Default Re: Display manufacturer list on category page

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.


---


---
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold
(CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module)
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 09:31 PM.

   

 
X-Cart forums © 2001-2020