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
  #11  
Old 03-24-2012, 03:58 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

You will need to make an array of the manufacturers unique to that category. Try something like:
In products.php:
Code:
foreach ($products as $k => $v) { $manuf_this_cat[$products[$k]['manufacturerid']] = $manuf_this_cat[$products[$k]['manufacturerid']]+1; } $smarty->assign('manuf_this_cat',$manuf_this_cat);

Then in the template, probably subcategories.php, you can go through that array:
Code:
{if $manuf_this_cat} <hr /> <ul> {foreach from=$manuf_this_cat key=k item=v} <li> manufacturerid:{$k}<br /> number items this cat:{$v}<br /> name: {$manufacturers.$k.manufacturer}<br /> </li> {/foreach} </ul> <hr /> {/if}
__________________
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

The following user thanks gb2world for this useful post:
Powertrain (03-24-2012)
  #12  
Old 03-24-2012, 10:38 PM
 
Powertrain Powertrain is offline
 

Senior Member
  
Join Date: Mar 2011
Posts: 101
 

Default Re: Display manufacturer list on category page

Quote:
Originally Posted by gb2world
You will need to make an array of the manufacturers unique to that category. Try something like:
In products.php:
Code:
foreach ($products as $k => $v) { $manuf_this_cat[$products[$k]['manufacturerid']] = $manuf_this_cat[$products[$k]['manufacturerid']]+1; } $smarty->assign('manuf_this_cat',$manuf_this_cat);

Then in the template, probably subcategories.php, you can go through that array:
Code:
{if $manuf_this_cat} <hr /> <ul> {foreach from=$manuf_this_cat key=k item=v} <li> manufacturerid:{$k}<br /> number items this cat:{$v}<br /> name: {$manufacturers.$k.manufacturer}<br /> </li> {/foreach} </ul> <hr /> {/if}

We are getting somewhere now

That code display this list in array:
  • manufacturerid:4
    number items this cat:6
    name: Dodge
  • manufacturerid:5
    number items this cat:1
    name: Ford
Now we need to display those manufacturers as links with name as anchor text?

Thanks.
__________________
x-cart 4.4.2 Gold
Reply With Quote
  #13  
Old 03-25-2012, 12:19 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

{if $manuf_this_cat}
<hr />
<ul>
{foreach from=$manuf_this_cat key=k item=v}
<li>
manufacturerid:{$k}<br />
number items this cat:{$v}<br />
name: {$manufacturers.$k.manufacturer}<br />
link: <a href="manufacturers.php?manufacturerid={$k}">{$man ufacturers.$k.manufacturer}</a>
</li>
{/foreach}
</ul>
<hr />
{/if}

---
__________________
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

The following user thanks gb2world for this useful post:
Powertrain (03-25-2012)
  #14  
Old 03-25-2012, 01:16 PM
 
Powertrain Powertrain is offline
 

Senior Member
  
Join Date: Mar 2011
Posts: 101
 

Default Re: Display manufacturer list on category page

That does it

I did notice a bug tho, manufacturer name that is displayed is wrong.

What I noticed is that it pulls correct masnufacturer IDs but displays wrong name.

Is it in the products.php code?

Thanks.
__________________
x-cart 4.4.2 Gold
Reply With Quote
  #15  
Old 03-25-2012, 01:57 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

Take care just when coping and pasting code from the forum - it looks like the forum software put an extra blank space in $manufacturers. I should have enclosed it in code tags

---
__________________
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
  #16  
Old 03-25-2012, 04:58 PM
 
Powertrain Powertrain is offline
 

Senior Member
  
Join Date: Mar 2011
Posts: 101
 

Default Re: Display manufacturer list on category page

Quote:
Originally Posted by gb2world
Take care just when coping and pasting code from the forum - it looks like the forum software put an extra blank space in $manufacturers. I should have enclosed it in code tags

---

I did caught that blank space and corrected it but still manufacturer name comes out wrong.

any idea?

Thanks.
__________________
x-cart 4.4.2 Gold
Reply With Quote
  #17  
Old 03-25-2012, 07:34 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

Reviewing the code I provided, it is escaping me how the id could be right and the name be off. You could have something in your cart instance that I am not considering.

You can debug it by using webmastermode and looking at the contents of the $manufacturers array and the $manuf_this_cat array and seeing where the data is wrong, then correcting the code from there.

---
__________________
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
  #18  
Old 03-27-2012, 01:04 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Display manufacturer list on category page

It looks like the original array only stores id=count with no name.

The manufacturer name is already there in $manufacturers_menu as in my earlier code example.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #19  
Old 03-27-2012, 02:24 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

I was thinking that $manufacturers used the actual id as the first key of the 2 dimensional array. But I did a quick check and the first key is just a counter - so my code needs to be fixed. No time to try this - syntax may be off, but something like this should do the trick:

In products.php:
Code:
foreach ($products as $k => $v) { $manufac_id = $products[$k]['manufacturerid']; $manuf_this_cat[$manufac_id] = func_query_first_cell ("SELECT manufacturer FROM $sql_tbl[manufacturers] WHERE $sql_tbl[manufacturers].manufacturerid='$manufac_id'"); } $smarty->assign('manuf_this_cat',$manuf_this_cat);

Then in the template:
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}
__________________
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
  #20  
Old 03-27-2012, 03:01 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Display manufacturer list on category page

Now on top of a new array there's an extra query for every product. I really don't recommend doing it like this. I would just use the data that is already there.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote

The following user thanks cherie for this useful post:
gb2world (03-27-2012)
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:37 PM.

   

 
X-Cart forums © 2001-2020