View Single Post
  #13  
Old 10-27-2007, 05:27 PM
 
MoonDog MoonDog is offline
 

Advanced Member
  
Join Date: Aug 2007
Posts: 93
 

Default Re: Display SubCategory titles with products

I just created something similar to what you need from an old posting a couple of days ago.
I just modified it a little to make it work on v4.1.8

First of all, kudos to the creator and all those that contributed to the original mod.

Start by opening up the xcart/include/categories.php file.
And find these lines of code: (it's at the bottom)
Code:
if (!empty($subcategories)) $smarty->assign("subcategories", $subcategories); $smarty->assign("cat", $cat); ?>
And right above those lines of code add:
Code:
//Subcategories in menu function sort_by_order_by($a, $b) { if ($a['order_by'] == $b['order_by']) { return 0; } return ($a['order_by'] < $b['order_by']) ? -1 : 1; } function func_getallsubcat() { $raj =func_get_categories_list("", true, "all"); $raj1=$raj['all_categories']; usort($raj1 ,"sort_by_order_by"); $ll=array(); foreach ($raj1 as $k=>$val) { if($val['parentid']!="0") { $ll[$val['parentid']][]=$val; } } return $ll; } $smarty->assign("allsubcategories", func_getallsubcat()); //Subcategorie in menu - end

Now, replace your skin1/customer/categories.tpl with this modified categories.tpl

Code:
{* $Id: categories.tpl,v 1.26 2005/11/17 06:55:37 max Exp $ *} {* modified *} <div id="sidenavcontainer"> {capture name=menu} {if $active_modules.Fancy_Categories ne ""} {include file="modules/Fancy_Categories/categories.tpl"} {assign var="fc_cellpadding" value="0"} {else} {if $config.General.root_categories eq "Y"} <ul id="mainmenu"> {foreach from=$categories item=c} {if $cat eq $c.categoryid || $current_category.parentid eq $c.categoryid} <li><h3><a class="current" href="home.php?cat={$c.categoryid}">{$c.category}</a></h3></li> {else} <li><h3><a href="home.php?cat={$c.categoryid}">{$c.category}</a></h3></li> {/if} {assign var=in value=$c.categoryid} {* CONDITIONAL DROP DOWN ITEMS FROM TOP CATEGORY *} <ul id="submenu"> {foreach from=$allsubcategories.$in item=c } {if $cat eq $c.categoryid} <li><h4><a class="current" href="home.php?cat={$c.categoryid}">{$c.category}</a></h4></li> {else} <li><h4><a href="home.php?cat={$c.categoryid}">{$c.category}</a></h4></li> {/if} {/foreach} </ul> {* /CONDITIONAL *} {/foreach} {else} {foreach from=$subcategories item=c key=catid} <li><a href="home.php?cat={$catid}">{$c.category}</a></li> {/foreach} {/if} </ul> {/if} </div> {/capture} { include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_categories menu_content=$smarty.capture.menu cellpadding=$fc_cellpadding}
And the last thing you need to do is copy the following code and add it to the bottom of your skin1.css file
Code:
/** * sidenavcontainer is 181px wide and a minimum of 400px high * It has a little padding top and bottom as well * Modify it to suit your layout */ html, body, ul, ol, li, p, h1, h2, h3, h4, h5, h6, form, fieldset, a { list-style-type: none; margin: 0; padding: 0; border: 0; } /*#sidenavcontainer { padding:200px 0 10px 0; PADDING-LEFT: 20px; PADDING-BOTTOM: 10px; width:181px; min-height:0px; float:left; } */ h3{ /* PRODUCT CATEGORIES */ padding:200; margin:100; font-size:11px; font-style:normal; font-weight:normal; } #sidenavcontainer h3 { margin:0 0 0 0px; padding:0px; } h4{ /* PRODUCT SUB-CATEGORIES */ padding:0; margin:0; font-size:11px; font-style:normal; font-weight:normal; } #sidenavcontainer h4 { margin:0 0 0 20px; padding:20; padding-bottom:2px; } #sidenavcontainer a { color:#000000; text-decoration:none; } #sidenavcontainer a:hover { color:#FF0000; text-decoration:none; } #sidenavcontainer .current { color:#3333FF; }

And that's it.

- MoonDog -
__________________
X-CART Gold v4.1.8
Reply With Quote