
Originally Posted by
gjh42
You can't have two cases active at the same time; that's not how switches work. What you want to do is add your second category to case 7.
PHP Code:
case 7://full active tree, others per level; always cat 23 & 150
if($cPath_top != $path_top and $path_top != '23' and $path_top != '150') $test_level = 1;
break;
Hi Glenn, I've run into a snag. I'm now trying to get my cat 150 to display subcats of active cats only. For some reason it's still displaying all of the subcats at all times, active or not. Can you help me modify this code to get what I need?
I have 3 sections to my nav:
-Shop by Category (default which displays subcats of active cats, the way I want it)
-Shop by Collection (cat 150)
-Shop by texture (cat 84)
My categories_dressing_functions.php looks like this:
Code:
function cat_active_level_manage($path) {
$skip_cat = 0;
if (defined('CAT_BOX_ACTIVE_LEVEL')) {
$test_level = 0;
$cat_box_active_level = explode('|',constant('CAT_BOX_ACTIVE_LEVEL'));
$cPath_top = (int)$_GET['cPath'];
$path_top = (int)$path;
$cat_depth = substr_count($path,'_');
//tests for various kinds of skipping - more can be added
switch ($cat_box_active_level[0]){
case 0:
$test_level = 1;
break;
case 1://active tree only
if($cPath_top != $path_top) $skip_cat = 1;
break;
case 2://active only (all tops when no cat selected)
if($cPath_top != $path_top and $cPath_top != 0) $skip_cat = 1;
break;
case 3://full active tree, others per level
if($cPath_top != $path_top) $test_level = 1;
break;
case 4://like 3, active branches only
if($cPath_top == $path_top){
if ($cat_depth >= 2){//only test sub-subcats+
$path_ids = explode('_',$path);
$path_parent = $path_ids[count($path_ids)-2];
if (!in_array($path_parent,explode('_',$_GET['cPath']))) $skip_cat = 1;//show only subcats w parent in $cPath
}
} else {//if not active test for level
$test_level = 1;
}
break;
case 5:// show active, no top, per levels
if ($cat_depth == 0 or $cPath_top != $path_top) {
$skip_cat = 1;
}else{
$test_level = 1;
}
break;
case 7://full active tree, others per level; always cat 23 & 150
if($cPath_top != $path_top and $path_top != '84' and $path_top != '150') $test_level = 1;
break;
}//switch
if ($test_level){
switch ('true'){
case ($cat_box_active_level[1] > $cat_depth):
$skip_cat = 1;
break;
case ($cat_box_active_level[2] < $cat_depth):
$skip_cat = 1;
break;
}//switch
}//if
}//defined
return $skip_cat;
}
My categories_dressing_defines.php looks contains this:
Code:
define ('CAT_BOX_HEADING_84','1|0|||<h3>By Texture</h3>|1');//new list - text heading - style 1
define ('CAT_BOX_HEADING_150','1|0|||<h3>By Collection</h3>|1');//new list - text heading - style 1
define('CAT_BOX_ACTIVE_LEVEL', '7|0|0'); //show only active cats, to first subcat level
Bookmarks