Forums / Setting Up Categories, Products, Attributes / Show Subcategories under Category Tabs

Show Subcategories under Category Tabs

Views: 1,117

Results 1 to 7 of 7
29 Mar 2012, 2:27 AM
#1
pyro_maniac avatar

pyro_maniac

New Zenner

Join Date:
Mar 2012
Posts:
5
Plugin Contributions:
0

Show Subcategories under Category Tabs

Hello,

Been researching posts for sometime trying to figure out how to make what I want work to no avail.

I am using the Category Tab Simple Dropdown Menu mod.

I have all sideboxes disabled and am only using the category tabs for navigation.

What I want to do is have all of the subcategories shown directly below the main categories dependent upon which main category is the lead category.

Example.
If I have:
Cat1, Cat2
Under Cat1: A, B, C
Under Cat2: D, E, F

If someone clicks on Cat1 or A or B or C. I would like all of the sub categories listed under the main category line.

Does that make sense?

Thanks for any ideas. Everything I have found in the forum is all about the category sideboxes which I am not using so it was hard to cross reference.

Thanks much for any input!

29 Mar 2012, 2:48 AM
#2
gjh42 avatar

gjh42

Black Belt

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

Re: Show Subcategories under Category Tabs

So you want essentially sidebox behavior... with the full tree of whatever top cat is in the cPath. I doubt the dropdown mods have the selectors built in for that, but it should be possible to add them with some extra PHP lookup and processing. Then you could make style rules to override the dropdown functionality and make children of the active top cat always display.

29 Mar 2012, 2:59 AM
#3
pyro_maniac avatar

pyro_maniac

New Zenner

Join Date:
Mar 2012
Posts:
5
Plugin Contributions:
0

Re: Show Subcategories under Category Tabs

Thanks for the reply!

Yes that is exactly what I want. Do you think it would be easier to copy the sidebox code to the tabs file and modify the styles?

Any direction on where I should start?

29 Mar 2012, 3:29 PM
#4
gjh42 avatar

gjh42

Black Belt

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

Re: Show Subcategories under Category Tabs

The dropdowns are already set up to work correctly in that orientation, so it would probably be simpler to just pull in the lookup code from a sidebox file. This would only be a few lines, depending on what information is already available to the dropdown.

29 Mar 2012, 4:17 PM
#5
pyro_maniac avatar

pyro_maniac

New Zenner

Join Date:
Mar 2012
Posts:
5
Plugin Contributions:
0

Re: Show Subcategories under Category Tabs

I am having a hard time determining which lines of code in the category sidebox is used for lookup. I am thinking it is somewhere in this section but am unsure how to implement it into the dropdown.

I am fairly familiar with PHP but it's been a while.

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 {
       $content .= '<div class="betterCategories"><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
	  if ($box_categories_array[$i]['current']) {
        if ($box_categories_array[$i]['has_sub_cat']) {
          $content .= '<span class="category-subs-parent">';
          $content .= cat_with_pointer($box_categories_array[$i]['name'], 'down', $spacer);
          $content .= '</span>';
        } else {
          $content .= '<span class="category-subs-selected">';
          $content .= cat_with_pointer($box_categories_array[$i]['name'], 'nosub', $spacer);
          $content .= '</span>';
        }
      } else {
        if ($box_categories_array[$i]['has_sub_cat']) { 
        $content .= cat_with_pointer($box_categories_array[$i]['name'], 'right', $spacer); }
        else { 
        $content .= cat_with_pointer($box_categories_array[$i]['name'], 'nosub', $spacer); }
      }

      if ($box_categories_array[$i]['has_sub_cat']) {
        $content .= CATEGORIES_SEPARATOR;
      }
29 Mar 2012, 7:39 PM
#6
gjh42 avatar

gjh42

Black Belt

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

Re: Show Subcategories under Category Tabs

if ($box_categories_array[$i]['current']) {

This is the line that fetches the active status for the sidebox (same array for stock sidebox or betterCategories), though I don't know if that array is used for the dropdown menu you are using. If it is not, then you will have to go deeper and figure out the status by comparing elements of $cPath with the category id being processed. There is code for that in several of my mods in Free Addons; Smart Backgrounds might have the simplest version of it.

29 Mar 2012, 7:52 PM
#7
gjh42 avatar

gjh42

Black Belt

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

Re: Show Subcategories under Category Tabs

$current = '';
if (in_array((/*id of category being processed - use the variable that gives this*/),explode('_',$_GET['cPath']))) $current = ' class="current"';
//insert $current into the <li> tag. 
//if there is already a potential class attribute being inserted there, modify the code above to only give ' current ' as the value of $current.