orignally posted by tacoma
Expanded Category - expand only to subcat1?
Using Expanded Category 2. I would like to just show category, and 1st subcategory.
I want all of the other subcategories to be hidden(collapsed).
Is there a way to do this?
Thanks.
gjh42:
Very easy. The category depth is shown in $cPath, with subcats separated by underscores _ . If it has one underscore, it is a first level subcat, two underscores = second level, etc. You can access that information for each prospective category in the list with
substr_count($box_categories_array[$i]['path'],'_')
Find this in /includes/templates/your_template/sideboxes/tpl_categories.php:
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 {
> substr_count($box_categories_array[$i]['path'],'_') > 1 or
> to get
> ```php
if (substr_count($box_categories_array[$i]['path'],'_') > 1 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 {
Glenn:
I misunderstood your first post offering the substr count code. I thought that was a modification to Clyde's Expanded Category List contribution which displays sub-categories and products at all times.
I now understand that your code modifies the original tpl_categories.php file (or a copy of same in the "custom" template folder).
When Clyde's contribution is used, we turn off categories.php in admin -> tools -> Layout Boxes Controller and turn on his categories_listing.php in it's place. Presumably this also switches to similarly named files in the classes, language, modules and template folders.
I did a WinMerge to compare tpl_categories.php and tpl_category_list_box.php and found that Clyde's tpl_categories_list_box.php is pretty much a complete rewrite and the code that your substr mod would be attached to does not exist there. Perhaps there is still a way to modify Clyde's contribution to limit the number of category sub-levels but I don't have the expertise to figure it out.
From what I can determine, your solution can't sucessfully be applied to the Expanded Category List contribution. If you get some time and want to, I hope you will look at tpl_categories_list_box.php from the contribution and see if there is a way to limit the number of sub-categories and prevent products from appearing in the Categories sidebox. It would be much appreciated. Meanwhile, thank you for the guidance. Ron