Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / HOW TO Show only current category in categories sidebox?

HOW TO Show only current category in categories sidebox?

Views: 1,003

Results 1 to 2 of 2
29 Jan 2012, 10:24 AM
#1
obrien48 avatar

obrien48

New Zenner

Join Date:
Apr 2009
Posts:
24
Plugin Contributions:
0

HOW TO Show only current category in categories sidebox?

Mods - please leave this up as it took me two days of searching to find this post and there were many unanswered questions asking for the same thing!

Guys, I took this from the '3 separated category boxes' thread. It's a simple mod that tells your categories box to display only the subcategories of the category you selected (are navigating to) - enjoy!

Credit goes to Glen for this one - my heartfelt thanks - I can now get some sleep!


In /includes/templates/your_template/sideboxes/tpl_categories.php, find this
PHP Code:
if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
// skip if this is for the document box (==3)
} else {
and add

substr_count($box_categories_array[$i]['path'],'_') == 0 or

to the if test to get this
PHP Code:
// subcat limit 2007-12-20
if (substr_count($box_categories_array[$i]['path'],'_') == 0 or zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
// skip if this is for the document box (==3)
} else {
The number of underscores in $box_categories_array[$i]['path'] indicates the category level, with 0 being a top cat.

The code can also be used to hide lower level subcats, with

$box_categories_array[$i]['path'] > 1

For more discussion of this, see the original thread Hide top category - Skip to subcategories.
##############################___
Glenn . . . Future Relics Jewelry, NY Faerie Festival
Categories Dressing, Images for Titles, Smart Backgrounds, Additional Img Titles, Ezpages Footer Columns, Model List...

30 Jan 2012, 3:45 AM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: HOW TO Show only current category in categories sidebox?

Since the time of that post, I have developed Categories Dressing to have the ability to choose this and several other display modes without editing code in PHP files, just putting a few numbers in a define file. If you only want the bare "hide top cats" functionality, the posted code still works fine.