hello gjh42,
I have the same problem in my category box. I want to hide/show also my categories in the sidebox. I opened the PHP file /includes/templates/template_default/sideboxes/tpl_categories.php to edit and place the "substr_count($box_categories_array[$i]['path'],'_') = 0" but I didn't find the place to be paste the code.
This is my tpl_categories.php code:
<?php
//print_r($box_categories_array);
//exit();
?>
<?php
//print_r($box_categories_array);
$content = "";
//$_test = '';
$content .= '<table width="210" border="0" cellspacing="0" cellpadding="0" style="padding-left:2px; padding-right:2px ;" id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">' . "\n";
$tabledeep = 0;
for ($i=0;$i<sizeof($box_categories_array);$i++) {
$sub_count = '';
$icon = '';
if (SHOW_COUNTS == 'true') {
if ((CATEGORIES_COUNT_ZERO == '1' and $box_categories_array[$i]['count'] == 0) or $box_categories_array[$i]['count'] >= 1) {
$sub_count = CATEGORIES_COUNT_PREFIX . $box_categories_array[$i]['count'] . CATEGORIES_COUNT_SUFFIX;
}
}
$firstitem = false;
$lastitem = false;
$doubleclose = false;
//if($i==39){
// echo '<br>$box_categories_array[$i]["top"] = '.$box_categories_array[$i]['top'];
// echo '<br>$box_categories_array[$i]["has_sub_cat"] = '.$box_categories_array[$i]['has_sub_cat'];
// echo '<br>$box_categories_array[$i]["type"] = '.$box_categories_array[$i]['type'];
// }
//echo 'type='.$box_categories_array[$i]['type'].'<br>';
switch(true) {
case ($box_categories_array[$i]['type'] == 'r' && $box_categories_array[$i]['type']!='p'):
$_width =15;
$content .= '<tr><td colspan="4" height="1" >'.zen_draw_separator('pixel_trans.gif', '10', '4').'</td></tr>';
$new_style = 'cate_root';
$icon = zen_image(DIR_WS_IMAGES.'sidebox/category-main-arrow.gif','','','',"style='cursor: hand;' onclick=\"openorclose('mybox_".($i+1)."')\"");
$link = zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']);
break;
case ($box_categories_array[$i]['has_sub_cat']):
//continue;
$new_style = 'cate_sub';
$icon = zen_image(DIR_WS_IMAGES.'sidebox/orange-arrow.png');
$link = zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']);
break;
case ($box_categories_array[$i]['type']=='p'):
if($box_categories_array[$i-1]['type']!='p' and !empty($box_categories_array[$i-1]))
{
$firstitem = true;
if($box_categories_array[$i+1]['type']=='r')
$tabledeep=2;
//echo "fristitem-";
}
if(($box_categories_array[$i+1]['type']!='p' and !empty($box_categories_array[$i+1])) or empty($box_categories_array[$i+1]))
{
$lastitem = true;
//echo "lastitem-";
}
if(($box_categories_array[$i+1]['type']=='r' or empty($box_categories_array[$i+1])))
{
$doubleclose = true;
//echo "double close AAA";
// echo $tabledeep."<br>";
}
$icon = zen_draw_separator('pixel_trans.gif', '20', '4');
$_width = 40;
$new_style = 'cate_products';
$link = zen_href_link(zen_get_info_page($box_categories_array[$i]['id']), 'products_id=' . $box_categories_array[$i]['id']);
if($box_categories_array[$i+1]['type']!='p')
$new_style = 'cate_products_last';
break;
default:
/**/if($box_categories_array[$i-1]['type'] == 'r'){
//echo "first c<br>";
$firstitem = true;
}
$new_style = 'cate_sub';
$_width = 20;
$icon = zen_image(DIR_WS_IMAGES.'sidebox/orange-arrow.png','','','',"id=\"IMG_$i\" style='cursor: hand;padding-left:6px;padding-right:6px' onclick=\"openorclose2('mybox_".($i+1)."','IMG_".$i."')\"");
$link = zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']);
}
if($box_categories_array[$i]['id']==34)
{
$link = 'man-p-34.html';
}
//$_test .= 'No.'.$i.' Name:'.$box_categories_array[$i]['name'].'-----------------------------<br>';
// $_test .= '$firstitem='.$firstitem.'<br>';
// $_test .= '$lastitem='.$lastitem.'<br>';
// $_test .= '$doubleclose='.$doubleclose.'<br>';
//if ($box_categories_array[$i]['type']=='p' and $box_categories_array[$i-1]['type']!='p')
//$content .= '<tr id="mybox_'.$i.'" style="display:none">';
//else
$content .= '<tr id="mybox_'.$i.'" class="'.$new_style.'">';
if($firstitem)
{ //echo $tabledeep;
//$tabledeep++;
$content .= '<td colspan="4"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>';
}
//echo $tabledeep.":";
$content .= '<td height="13" align="center" class="' . $new_style . '_tree1" width="'.$_width.'" >'. $icon . '</td><td width="100%" height="13" class="' . $new_style . '_tree2">';
if($box_categories_array[$i]['type'] == 'p')
$content .= '<a href="' . $link . '" title="' . zen_get_products_name($box_categories_array[$i]['id'],2) . '">';
else
$content .= '<a href="' . $link . '" >';
$content .= $box_categories_array[$i]['name'] . $sub_count ;
$content .= '</a></td>';
//echo zen_get_all_get_params(array('action')) ;
// exit(); disp_order=8&
if($box_categories_array[$i]['type'] == 'p'){
$image1 = '<a href="'. $link .'">'.zen_image(DIR_WS_IMAGES.'sidebox/searchLogo.gif','View more detail about'.zen_get_products_name($box_categories_array[$i]['id'],2)).'</a>';
$image2 = zen_draw_form('box_cart_'.$box_categories_array[$i]['id'], zen_href_link(zen_get_info_page($box_categories_array[$i]['id']), zen_get_all_get_params(array('action')) . 'products_id='.$box_categories_array[$i]['id'].'&action=add_product'), 'post', 'enctype="multipart/form-data"')."\n";
//echo $box_categories_array[$i]['id'];
if($box_categories_array[$i]['id']=='70'){
$image2 = zen_draw_form('box_cart_'.$box_categories_array[$i]['id'], zen_href_link(zen_get_info_page(55), zen_get_all_get_params(array('action')) . 'products_id=55&action=add_product'), 'post', 'enctype="multipart/form-data"')."\n";
}
if($box_categories_array[$i]['id']==71){
$image2 = zen_draw_form('box_cart_'.$box_categories_array[$i]['id'], zen_href_link(zen_get_info_page(48), zen_get_all_get_params(array('action')) . 'products_id=48&action=add_product'), 'post', 'enctype="multipart/form-data"')."\n";
}
if($box_categories_array[$i]['id']>=88 && $box_categories_array[$i]['id']<=99){
$image2 = zen_draw_form('box_cart_'.$box_categories_array[$i]['id'], zen_href_link(zen_get_info_page(86), zen_get_all_get_params(array('action')) . 'products_id=86&action=add_product'), 'post', 'enctype="multipart/form-data"')."\n";
}
if($box_categories_array[$i]['id']==102){
$image2 = zen_draw_form('box_cart_'.$box_categories_array[$i]['id'], zen_href_link(zen_get_info_page(50), zen_get_all_get_params(array('action')) . 'products_id=50&action=add_product'), 'post', 'enctype="multipart/form-data"')."\n";
}
//$image2 .= zen_image_submit(BUTTON_IMAGE_ADD_PRODUCTS_TO_CART_SMALL,'$'.$box_categories_array[$i]['price'],'id="submit_'.$box_categories_array[$i]['id'].'" name="submit_'.$box_categories_array[$i]['id'].'"');
$image2 .= zen_image(DIR_WS_IMAGES.'sidebox/cartLogo.gif','Buy '.zen_get_products_name($box_categories_array[$i]['id'],2).' only '.'$'.$box_categories_array[$i]['price'],'','','style="cursor:pointer;" onclick="box_cart_' .$box_categories_array[$i]['id']. '.submit();"');
$image2 .= zen_draw_hidden_field('products_id', (int)$box_categories_array[$i]['id']);
$image2 .= zen_draw_hidden_field('cart_quantity',1);
$image2 .= '</form>';
$content .= '<td class="'.$new_style.'_tree3">'. $image1 .'</td>';
$content .= '<td class="'.$new_style.'_tree4">'. $image2 .'</td>';
}
else
$content .= '<td class="'.$new_style.'_tree3">'.zen_draw_separator('pixel_trans.gif', '1', '1').'</td><td class="'.$new_style.'_tree4">'.zen_draw_separator('pixel_trans.gif', '1', '1').'</td>';
$content .= '</tr>';
if($lastitem)
{
//$tabledeep-=1;
$content .= '</table></td></tr>';
if($tabledeep==2){
$tabledeep=0;
}else if($doubleclose){
$tabledeep-=1;
$content .= '</table></td></tr>';
}
}
//echo $tabledeep.";";
}
$content .= '</table><table><tr><td colspan="4" height="1" >'.zen_draw_separator('pixel_trans.gif', '10', '4').'</td></tr></table>';
//echo "------------------------------------------------------------";
//echo $content;
//exit();
//echo "test=".$_test;
//exit();
?>
This tpl_categories.php was been coded in my first php coder and It was really hard to understand his code. Please help me to find where to edit or what should I do. I want to hide and show the categories also from root to subcategories.
Target (it should be):
School Bags (root category)
School Uniform
School Utility
The sub-category should be hide and only the root category will show. Once you have clicked the button of the root category the list of sub cat will show.
Please help me guys.. Thank you very much..
:(