View Single Post
  #2  
Old 06-07-2008, 04:30 PM
 
toltion toltion is offline
 

Advanced Member
  
Join Date: Jun 2007
Posts: 39
 

Default Re: Display a list of Subcategories from a Specific Category

I needed this too, so I looked at fly-out menu examples and came up with this -

I like to show third-level categories in fourth level subcategories (i.e. all subcategories that share the same parent category of the current category) -

---------------------
{foreach from=$categories item=c}{* list ROOT categories *}
{if $c.subcats gt 0}
{foreach from=$c.subcats item=c2 name=c2}{* list 2nd level subcategories *}

{if $c2.categoryid eq $current_category.parentid}
{assign var='parent_category' value=$c2.category}{* get the name of the Parent Category *}
{/if}

{if $c2.subcats gt 0}
{foreach from=$c2.subcats item=c3 name=c3}{* list 3rd level subcategories *}
{if $c3.parentid eq $current_category.parentid}
<a href="home.php?cat={$c3.categoryid}">{$c3.category }</a><br />
{/if}
{/foreach}
{/if}
{/foreach}
{/if}
{/foreach}
<a href="home.php?cat={$current_category.parentid}">{ $parent_category}</a><br />{* link to Parent Category at end of list *}
----------------

This creates a basic array of categories that share the same parent category of the current 4th level category. You could, of course, easily modify it to show deeper levels.
__________________
X-Cart Gold 4.1.9
Gift Registry/Special Offers
Advanced mini-cart
XC-SEO
Mulltiple Category/Product Templates
Also bought/recently viewed
Feedback reviewer/viewer bundle
Marketing Manager Pro bundle
many more mods
Reply With Quote