Forums / Templates, Stylesheets, Page Layout / subcategories only in sidebox main categories top

subcategories only in sidebox main categories top

Locked

Views: 5,966

Results 21 to 28 of 28
This thread is locked. New replies are disabled.
19 Oct 2008, 1:31 AM
#21
mcanes avatar

mcanes

Zen Follower

Join Date:
May 2007
Posts:
210
Plugin Contributions:
0

subcategories only in sidebox main categories top

Glenn, here is an example of what I mean (click here). You can see that the categories box shows up, but it is empty. I would like in this scenario to show the top level categories like NFL Team Store, NCAA Team Store, MLB Team Store, etc.

Thanks for your help.

19 Oct 2008, 4:17 AM
#22
gjh42 avatar

gjh42

Black Belt

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

Re: subcategories only in sidebox main categories top

A tweak to allow the top cats to show when there is no current category (i.e. other than category/product pages):
Add as shown

or !$GET['cPath'] /nothing current - show all sports/```php
$skip_this = true;
if (($box_categories_array[$i]['current'] and $box_categories_array[$i]['top']) /show current sport/ or ($box_categories_array[$i]['current'] and substr_count($box_categories_array[$i]['path'],'
') == 1) /show current team/ or substr_count($box_categories_array[$i]['path'],'_') > 1 /show all product types/ or !$_GET['cPath'] /nothing current - show all sports/) {
$skip_this = false;
}
if ($skip_this == true 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 {

19 Oct 2008, 3:26 PM
#23
mcanes avatar

mcanes

Zen Follower

Join Date:
May 2007
Posts:
210
Plugin Contributions:
0

Re: subcategories only in sidebox main categories top

Glenn, that worked great. Thank you so much. I have one other question you may be able to help me with...

Do you know why when I go to a page like my contact us (click here) there is no category sidebox? Did I remove it somehow and not realize. It dpes this on a few pages, but not many.

Thanks

20 Oct 2008, 6:59 PM
#24
gjh42 avatar

gjh42

Black Belt

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

Re: subcategories only in sidebox main categories top

It is possible to add/change code to not show a certain sidebox on certain pages, but it is not something you could have done by accident. Could you have forgotten about having done it?

22 Oct 2008, 1:31 AM
#25
mcanes avatar

mcanes

Zen Follower

Join Date:
May 2007
Posts:
210
Plugin Contributions:
0

Re: subcategories only in sidebox main categories top

Glenn, looks like I misssed something... When you go to an item all the categories come back (click here). Your help is appreciated.

22 Oct 2008, 7:06 AM
#26
gjh42 avatar

gjh42

Black Belt

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

Re: subcategories only in sidebox main categories top

I'm not sure I can actually help, but maybe I can point out something relevant to the problem.

The cPath to the product in question is not clear. The categories box suggests it is in one of the subcats of Alabama Crimson Tide; the breadcrumbs suggest it is directly in Alabama Crimson Tide, not in a subcat; and the address bar says that it is in the /auburn-tigers-282/flags-banners-1398/ subcat, not in Alabama Crimson Tide at all.

Your SEO mod seems to be messing up the path information, which may in turn be causing $cPath to be incorrect or empty in this case. If it is empty, the code will display all categories in the standard manner (which is what appears to be happening).

17 Dec 2009, 10:41 AM
#27
adi2009 avatar

adi2009

New Zenner

Join Date:
Dec 2009
Location:
Sarajevo
Posts:
80
Plugin Contributions:
0

Re: subcategories only in sidebox main categories top

gjh42:

The easiest way to do this is probably by adding a switch that suppresses output of any category that is not current and a subcat.
Find this line in /includes/templates/your_template/sideboxes/tpl_categories.php```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 {

> 
> and add
> $current_top = false;
> if ((int)str_replace("cPath=","",$box_categories_array[$i]['path']) == $_GET['cPath']) { //top cat of path is active
> $current_top = true;
> }
> 
> above it, and
> 
> ($current_top == false) or ($box_categories_array[$i]['top'] == 'true') or
> inside it to get```php
$current_top = false;
if ((int)str_replace("cPath=","",$box_categories_array[$i]['path']) == $_GET['cPath']) { //top cat of path is active
$current_top = true;
}
if (($current_top == false) or ($box_categories_array[$i]['top'] == 'true') 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 {

I haven't tested this yet, so try it and let me know how it works. If it needs tweaking, I'll take care of it.

Works great for my site too! :flex: thnx Glenn!

Only difference is that my template (zenflavr., "free templ.1") dosesnt contain "tpl_categories.php" in includes/templates/mytemplate/sideboxes/" so I had to copy "tpl_categories" that file from /templates/template_default":wink:

MY Website
The best of the best: Zen Cart

17 Dec 2009, 10:56 AM
#28
gjh42 avatar

gjh42

Black Belt

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

Re: subcategories only in sidebox main categories top

Any file will only be in your custom template folders if you have edited it and saved it there; the /includes/templates/your_template/sideboxes/tpl_categories.php is short for "copy this file from /template_default/sideboxes/ and save it to /your_template/sideboxes/ if there is not already a copy there".