View Single Post
  #33  
Old 12-31-2009, 11:31 AM
  thatcrazyartguy's Avatar 
thatcrazyartguy thatcrazyartguy is offline
 

Advanced Member
  
Join Date: Nov 2008
Posts: 34
 

Default Re: Manufacturer Categories mod! Free!

Quote:
Originally Posted by paryaei
Hi

I am really interested to know how to do this. If you could please post the code I would really appreciate it.

Sure...

Here is what I added to manufacturer_categories.php

First, I added a new value to the $man_categories array called "master_header".

Then...

I made a new array called "master_headers" that contains all the main headings based on the "category_path" of the category data. This is the same value that is applied to the "master_header" key of $man_categories.

This is directly under "$mode = ' ';" (around line 67)

---------------------------------------
$master_headers = array();
$count = "0";
foreach($man_categories as $k=>$v){
$get_top = explode("/",$man_categories[$k]['category_path']);
$man_categories[$k]['master_header'] = $get_top[0];
if(!in_array($get_top[0],$master_headers)){
$master_headers[$count] = $get_top[0];
$count++;
}
}
sort($master_headers);
$smarty->assign("master_headers",$master_headers);
---------------------------------------

This is what I changed in manufacturer_categories.tpl

This replaces the foreach loop in the original.
Just below <hr class="mcat_hr"> - Replaces Lines 60 - 77

It begins by looping through each of the values of the "master_headers" array. Then, it loops through $man_categories displaying all the links and info for each category that falls under the corresponding main headers.

----------------------------------------
{foreach item=master from=$master_headers}
<div style="margin:1em 0 1em 0">
<div style="background-color:#f8f008; font-size:18px; padding:.5em; margin-bottom:.25em">{$master}</div>
{foreach item=mcat from=$man_categories}
<div style="padding-left:1em">
{if ($mcat.master_header eq $master)}
<a href=
"{$catalogs.customer}/manufacturers.php?manufacturerid={$manufacturerid} &catid={$mcat.categoryid}"
style="font-size:12px" class="mcat_link">{$manufacturer.manufacturer} {$mcat.category}</a><br />
{/if}
</div>
{/foreach}
</div>
{/foreach}
----------------------------------------
your {else} should begin just below the code above.

I hope this helps. Any comments or suggestions on this would be very welcome.

JB
Reply With Quote