New Zenner
- Join Date:
- Jan 2011
- Location:
- Brooklyn
- Posts:
- 75
- Plugin Contributions:
- 0
Changing color of Categories and Sub-Categories
gjh42:
Edit your /includes/templates/your_template/sideboxes/tpl_categories.php. Find this near the top:```php
// many variations of this can be done
// case ($box_categories_array[$i]['path'] == 'cPath=3'):
// $new_style = 'category-holiday';
// break;
case ($box_categories_array[$i]['top'] == 'true'):
$new_style = 'category-top';
break;
case ($box_categories_array[$i]['has_sub_cat']):
$new_style = 'category-subs';
break;
default:
$new_style = 'category-products';
}
>
> . (substr_count($box_categories_array[$i]['path'],'_') = 2)? '2': ''
>
> in two places to get```php
// many variations of this can be done
// case ($box_categories_array[$i]['path'] == 'cPath=3'):
// $new_style = 'category-holiday';
// break;
case ($box_categories_array[$i]['top'] == 'true'):
$new_style = 'category-top';
break;
case ($box_categories_array[$i]['has_sub_cat']):
$new_style = 'category-subs' . (substr_count($box_categories_array[$i]['path'],'_') = 2)? '2': '';//class .category-subs2 for sub-subcat
break;
default:
$new_style = 'category-products' . (substr_count($box_categories_array[$i]['path'],'_') = 2)? '2': '';//class .category-products2 for sub-subcat
}
```and add
>
> a.category-subs2, a.category-products2 {color: #336699;}
>
> This will strictly make new classes for second-level subcats, no more, no less.
> A simpler mod that will distinctly identify all levels of subcats is to add
>
> . substr_count($box_categories_array[$i]['path'],'_')
>
> to get```php
// many variations of this can be done
// case ($box_categories_array[$i]['path'] == 'cPath=3'):
// $new_style = 'category-holiday';
// break;
case ($box_categories_array[$i]['top'] == 'true'):
$new_style = 'category-top';
break;
case ($box_categories_array[$i]['has_sub_cat']):
$new_style = 'category-subs' . substr_count($box_categories_array[$i]['path'],'_');//class .category-subsx for subcat level x
break;
default:
$new_style = 'category-products' . substr_count($box_categories_array[$i]['path'],'_');//class .category-productsx for subcat level x
}
```and replace the
>
> a.category-subs, a.category-products {}
>
> in your stylesheet with
>
> a.category-subs1, a.category-products1 {color: #7733ff;}
>
> a.category-subs2, a.category-products2 {color: #336699;}
>
> etc.
I LOVE THIS!! I just implemented it on my site. THIS SHOULD BE STANDARD ON ZENCART! How do I nominated this for inclusion?
I've been searching for days for a solution for how to style sub-cats within sub-cats within sub-cats on my leftside menu. This deserves it's own thread!
This is my result. I still need to work on making the levels more distinct. But I'm thrilled it can be done!
<http://focalpointhardware.net/index.php?main_page=index&cPath=11_12_15_17_20>
Thanks, gjh42! You are the Zenest of the Zen.