Forums / Setting Up Categories, Products, Attributes / Not all subcategories appearing in sidebox

Not all subcategories appearing in sidebox

Views: 1,536

Results 1 to 18 of 18
14 Apr 2013, 4:40 PM
#1
chri55yb0y avatar

chri55yb0y

New Zenner

Join Date:
Apr 2013
Location:
United Kingdom
Posts:
11
Plugin Contributions:
0

Not all subcategories appearing in sidebox

Hi,

First post so hopefully I am in the right section!

Running v1.51 with a custom template, currently running in showcase mode until it's ready.

I have set up a selection of categories with sub categories and in the process I created some sub categories in the wrong category. Hope you with me so far:blush:

So I used the "move" feature and relocated those subcategories to the correct category, all good so far, however when I click on the category in the sidebox on the webpage, the subcategories I moved do not show in the sidebox, only in the main page. The other subcategories appear just fine in the sidebox.

Is there anything I can check or do....or do I have to delete the "moved" subcategories and recreate them.

Hope that makes some sense and hope someone can help me out

Thanks

14 Apr 2013, 4:53 PM
#2
get_em_fast avatar

get_em_fast

Totally Zenned

Join Date:
Dec 2006
Location:
Seligman, MO U.S.A.
Posts:
2,072
Plugin Contributions:
1

Re: Not all subcategories appearing in sidebox

An address to your site, and a list of the sub's that you moved would be a big help for someone to help you. If we can actually SEE it, we can sometimes find the problem MUCH better.

Teach them to shop and they will shop today;
Teach them to Zen and they will OWN a shop tomorrow!

14 Apr 2013, 5:25 PM
#3
chri55yb0y avatar

chri55yb0y

New Zenner

Join Date:
Apr 2013
Location:
United Kingdom
Posts:
11
Plugin Contributions:
0

Re: Not all subcategories appearing in sidebox

Get Em Fast:

An address to your site, and a list of the sub's that you moved would be a big help for someone to help you. If we can actually SEE it, we can sometimes find the problem MUCH better.

Sorry....

http://www.barkerandcummings.com

Product category is: OCCASION

The ones that were moved to there:

Christenings
Birthdays
New Baby
Wedding

Thanks

14 Apr 2013, 5:45 PM
#4
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Not all subcategories appearing in sidebox

Hard to say what happened, but it looks like you don't have any products in those subcategories yet, so I would just delete them and recreate them in the proper category.

14 Apr 2013, 5:53 PM
#5
chri55yb0y avatar

chri55yb0y

New Zenner

Join Date:
Apr 2013
Location:
United Kingdom
Posts:
11
Plugin Contributions:
0

Re: Not all subcategories appearing in sidebox

OK thanks, I'll do that now :)

14 Apr 2013, 5:58 PM
#6
chri55yb0y avatar

chri55yb0y

New Zenner

Join Date:
Apr 2013
Location:
United Kingdom
Posts:
11
Plugin Contributions:
0

Re: Not all subcategories appearing in sidebox

Hmm well I've deleted the ones I moved and just recreated/added new one and it still doesn't appear in sidebox :(

Didn't really want to delete the top category

14 Apr 2013, 6:26 PM
#7
chri55yb0y avatar

chri55yb0y

New Zenner

Join Date:
Apr 2013
Location:
United Kingdom
Posts:
11
Plugin Contributions:
0

Re: Not all subcategories appearing in sidebox

Well I have discovered what the issue is, it seems I can not have subcategory within a subcategory.

File structure starts as
Occasions>
Occasions>Christening

Then I wanted some subs in there:

Occasions>Christening>Baby boy
Occasions>Christening>Baby girl

and so on but as soon as I add those it removes "Christening" from the sidebox, am I doing something wrong on the creation of the second subs or is this a limitation by default?

Thanks

14 Apr 2013, 7:25 PM
#8
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Not all subcategories appearing in sidebox

I would say you're doing something wrong, as Zencart allows unlimited subcategory levels. One thing Zencart doesn't allow is products and sub-categories within the same (sub-) category. Are you trying to do that ?

14 Apr 2013, 7:34 PM
#9
chri55yb0y avatar

chri55yb0y

New Zenner

Join Date:
Apr 2013
Location:
United Kingdom
Posts:
11
Plugin Contributions:
0

Re: Not all subcategories appearing in sidebox

stevesh:

I would say you're doing something wrong, as Zencart allows unlimited subcategory levels. One thing Zencart doesn't allow is products and sub-categories within the same (sub-) category. Are you trying to do that ?

Definitely not adding products, created top level Occasions, the "new category" and then again for the next sub.

So if I get to :

Occasions>Birthdays>Her

"Birthdays" disappears as subcategory under Occasions from the sidebox but everything is still displayed correctly in the main page area.

Could this be a code issue for the sidebox template perhaps?

thanks

14 Apr 2013, 7:57 PM
#10
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Not all subcategories appearing in sidebox

What's the category id number for Occasions - Birthdays - Her ? What happens if you temporarily switch back to the Classic template ?

14 Apr 2013, 8:10 PM
#11
chri55yb0y avatar

chri55yb0y

New Zenner

Join Date:
Apr 2013
Location:
United Kingdom
Posts:
11
Plugin Contributions:
0

Re: Not all subcategories appearing in sidebox

stevesh:

What's the category id number for Occasions - Birthdays - Her ? What happens if you temporarily switch back to the Classic template ?

Category ID Occasions (66) > Birthdays (67) > Her (80)

I just switched back to classic green and the sidebox shows correctly but switched back to custom and it goes again, just for info I am using the "estorenow" template.

Thanks for you input :)

14 Apr 2013, 9:05 PM
#12
chri55yb0y avatar

chri55yb0y

New Zenner

Join Date:
Apr 2013
Location:
United Kingdom
Posts:
11
Plugin Contributions:
0

Re: Not all subcategories appearing in sidebox

Ok so I've subbed the tpl_categories.php file with the original from classic and the categories work albeit not cosmetically formatted.

This is the code from the tpl_categories.php from the "estorenow" template, I'm not familiar enough with PHP to see what if anything is wrong here, would someone be kind enough to look over this please?

<?php /** * Side Box Template * * @package templateSystem * @copyright Copyright 2003-2006 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 * @version $Id: tpl_categories.php 4162 2006-08-17 03:55:02Z ajeh $ */ $content = ""; $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent"><ul id="cat">' ; $ul_close='YES';//YES NO for ($i=0;$i<sizeof($box_categories_array);$i++) { switch(true) { // to make a specific category stand out define a new class in the stylesheet example: A.category-holiday // uncomment the select below and set the cPath=3 to the cPath= your_categories_id // 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'; } 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 { /////////////////////////////1.1///////////////////////// if($box_categories_array[$i]['has_sub_cat'] && $new_style == 'category-top' ){ if($ul_close=='NO'){ $content =$content.'</ul></li>'; $ul_close='YES'; } $ul_close='NO'; $content .= '<li><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">'; $content .= $box_categories_array[$i]['name']; $content =$content.'</a><ul>'; }//new addon for <li> /////////////////1.2/////////////////////////////// elseif($box_categories_array[$i]['has_sub_cat']==false&&$new_style == 'category-products'){// for child $content .= '<li><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">'; $content .= $box_categories_array[$i]['name']; $content =$content.'</a></li>'; if($i==(sizeof($box_categories_array)-1)){//last li ele $content =$content.'</ul></li>'; } //////////////////1.3///////////////// }elseif($box_categories_array[$i]['has_sub_cat']==false&&$new_style == 'category-top'){ if($ul_close=='NO'){ $content =$content.'</ul></li>'; $ul_close='YES'; } $content .= '<li><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">'; $content .= $box_categories_array[$i]['name']; $content =$content.'</a></li>'; //////////////////////////// if (false) {//display counts if ((CATEGORIES_COUNT_ZERO == '1' and $box_categories_array[$i]['count'] == 0) or $box_categories_array[$i]['count'] >= 1) { $content .= CATEGORIES_COUNT_PREFIX . $box_categories_array[$i]['count'] . CATEGORIES_COUNT_SUFFIX; } } } //eof new adds on }//end of else }//eof for loop /////////////////////////////////////////////////////////////////////////////////////////// if (SHOW_CATEGORIES_BOX_SPECIALS == 'true' or SHOW_CATEGORIES_BOX_PRODUCTS_NEW == 'true' or SHOW_CATEGORIES_BOX_FEATURED_PRODUCTS == 'true' or SHOW_CATEGORIES_BOX_PRODUCTS_ALL == 'true') { // display a separator between categories and links if (SHOW_CATEGORIES_BOX_SPECIALS == 'true') {//display specials $show_this = $db->Execute("select s.products_id from " . TABLE_SPECIALS . " s where s.status= 1 limit 1"); if ($show_this->RecordCount() > 0) { $content .= '<li><a class="category-links" href="' . zen_href_link(FILENAME_SPECIALS) . '">' . CATEGORIES_BOX_HEADING_SPECIALS . '</a></li>'; } } if (SHOW_CATEGORIES_BOX_PRODUCTS_NEW == 'true') {//displal new products // display limits // $display_limit = zen_get_products_new_timelimit(); $display_limit = zen_get_new_date_range(); $show_this = $db->Execute("select p.products_id from " . TABLE_PRODUCTS . " p where p.products_status = 1 " . $display_limit . " limit 1"); if ($show_this->RecordCount() > 0) { $content .= '<li><a class="category-links" href="' . zen_href_link(FILENAME_PRODUCTS_NEW) . '">' . CATEGORIES_BOX_HEADING_WHATS_NEW . '</a></li>' ; } } if (SHOW_CATEGORIES_BOX_FEATURED_PRODUCTS == 'true') {//display featured products $show_this = $db->Execute("select products_id from " . TABLE_FEATURED . " where status= 1 limit 1"); if ($show_this->RecordCount() > 0) { $content .= '<li><a class="category-links" href="' . zen_href_link(FILENAME_FEATURED_PRODUCTS) . '">' . CATEGORIES_BOX_HEADING_FEATURED_PRODUCTS . '</a></li>'; } } if (SHOW_CATEGORIES_BOX_PRODUCTS_ALL == 'true') { $content .= '<li><a class="category-links" href="' . zen_href_link(FILENAME_PRODUCTS_ALL) . '">' . CATEGORIES_BOX_HEADING_PRODUCTS_ALL . '</a></li>'; } } $content .= '</ul></div>'; ?>
16 Apr 2013, 1:57 AM
#13
gjh42 avatar

gjh42

Black Belt

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

Re: Not all subcategories appearing in sidebox

This is not the only file causing the error (though it is outputting the error). It can be really hard to debug program logic flow by looking at a file without running it, but I notice that all of the subcats and sub-subcats have a .category-products class assigned where some should have .category-subs.

There is some incomplete logic in this file. It only allows for top cats with subcats, top cats without subs, or subcats without subs. Subcats with subcats will not be handled by that part of the code and will not be output at all (when I go to cPath=66_67_80 I do see Occasions > Her listed as a sub-subcat, but not Birthdays as the parent of Her).

A previous file in the stream is not assigning the correct value to $box_categories_array[$i]['has_sub_cat'], thus subcats with subcats are ignored by the sidebox. The two errors compound each other. I find it hard to imagine such an erroneous result being overlooked by all previous people who have used the template, but anything is possible...

16 Apr 2013, 2:24 AM
#14
gjh42 avatar

gjh42

Black Belt

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

Re: Not all subcategories appearing in sidebox

Okay, correction to the logic flow...
Maybe the subcats with subcats are being assigned the correct class tag, but as the code ignores these subcats for output, we can't know without some debug code added.

The first thing to do would be to add the missing logic to handle subcats with subcats. Something like (find this)```php
// skip if this is for the document box (==3)
} else {
/////////////////////////////1.1/////////////////////////
if($box_categories_array[$i]['has_sub_cat'] && $new_style == 'category-top' ){

if($ul_close=='NO'){
$content =$content.'</ul></li>';
$ul_close='YES';
}
$ul_close='NO';
$content .= '<li><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
$content .= $box_categories_array[$i]['name'];

$content =$content.'</a><ul>';
}//new addon for <li>
/////////////////1.2///////////////////////////////
add another section after this one:php
// skip if this is for the document box (==3)
} else {
/////////////////////////////1.1/////////////////////////
if($box_categories_array[$i]['has_sub_cat'] && $new_style == 'category-top' ){

if($ul_close=='NO'){
$content =$content.'</ul></li>';
$ul_close='YES';
}
$ul_close='NO';
$content .= '<li><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
$content .= $box_categories_array[$i]['name'];

$content =$content.'</a><ul>';
}//new addon for <li>
///////////1.1a/////////////////
elseif($new_style == 'category-subs' ){//subcat with subcats

//if($ul_close=='NO'){//not sure how this section should work yet, need to study it more
//$content =$content.'</ul></li>';
//$ul_close='YES';
//}
$ul_close='NO';
$content .= '<li><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
$content .= $box_categories_array[$i]['name'];

$content .= '</a><ul>';
}//new addon for <li>
/////////////////1.2///////////////////////////////
elseif($box_categories_array[$i]['has_sub_cat']==false&&$new_style == 'category-products'){// for child

16 Apr 2013, 5:51 AM
#15
chri55yb0y avatar

chri55yb0y

New Zenner

Join Date:
Apr 2013
Location:
United Kingdom
Posts:
11
Plugin Contributions:
0

Re: Not all subcategories appearing in sidebox

Thanks for taking the time to look I really appreciate it.

I will try your suggestion when I get home tonight.

Thanks again

16 Apr 2013, 4:11 PM
#16
gjh42 avatar

gjh42

Black Belt

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

Re: Not all subcategories appearing in sidebox

If you find that this fixes it, you should really report the bug and the solution to the template source. If it doesn't fix it, report the bug, as it is the author's responsibility to make it work correctly.

16 Apr 2013, 5:53 PM
#17
chri55yb0y avatar

chri55yb0y

New Zenner

Join Date:
Apr 2013
Location:
United Kingdom
Posts:
11
Plugin Contributions:
0

Re: Not all subcategories appearing in sidebox

gjh42:

If you find that this fixes it, you should really report the bug and the solution to the template source. If it doesn't fix it, report the bug, as it is the author's responsibility to make it work correctly.

OK, do I do that through the template section of this site (It was downloaded from Zen site)? surprised it's not been spotted before I can't be the only person doing more than one sub cat :unsure:

Anyhow, I've taken your amendments and added as you suggested which didn't fix to start with, so as per below code I've uncommented a section and it now appears correctly on the site. The only issue I have now though is alignment, I've added a ".category-subs" to my css sheet which has provisionally put arr.gif in front the category. But as you can see "Birthdays" is now a few pixels left of the other sub categories, is this purely finding the right tag in the css file?

Thanks again, appreciate your time :smile:

 ////////////////1.1a////////////////
	  elseif( $new_style == 'category-subs' ){//subcat with subcats
	  if($ul_close=='NO'){//not sure how this section should work yet, need to study it more
  $content =$content.'</ul></li>';
  $ul_close='YES';
}
$ul_close='NO';
$content .= '<li><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
$content .= $box_categories_array[$i]['name'];

$content .= '</a><ul>';
16 Apr 2013, 10:11 PM
#18
gjh42 avatar

gjh42

Black Belt

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

Re: Not all subcategories appearing in sidebox

This display reveals another aspect of the incompleteness of the <ul> handling of this menu: When the sub-subcats end and a new top cat is displayed, it needs to close two levels of <ul>, but it only is able to close one, so all of the following items are inside the first top category's list. It needs to keep track of the nesting level of lists so that it can format them correctly. I spent a lot of time getting this right for Categories Dressing, with much more complex possibilities than this mod presents, and don't want to reinvent it now.

At any rate, you can find the author's name and/or contact info in the mod's readme documentation somewhere, and I would suggest sending them to this thread to see the whole issue.

Meanwhile, if you want to have a fully and correctly functioning menu with distinctions between levels and kinds of categories, you could install Categories Dressing. It has numerous features which you would probably need to turn off, but you can do about anything you can imagine with the categories sidebox using it. It would obviously need restyling to become consistent with what you have; post in the Categories Dressing support thread if you need help with that.