If this is your first visit, check our documentation. To post, register or login.
Forums / Setting Up Your Zen Cart Products / Setting Up Categories, Products, Attributes / Is there any way of adding products to a category with subcategories?

Is there any way of adding products to a category with subcategories?

Locked

Started by chaiavi on 8 Dec 2010, 3:22 PM · Views: 1,250

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
8 Dec 2010, 4:24 PM
#2
stevesh avatar

stevesh

Black Belt

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

Post #2 by stevesh

Yes, but it's strongly recommended that you don't do that, as it can cause all sorts of problems with your product listings.

See post #4 here:

http://www.zen-cart.com/forum/showthread.php?t=166416

8 Dec 2010, 4:58 PM
#3
gjh42 avatar

gjh42

Black Belt

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

Post #3 by gjh42

The most visible problem is that, if there are products and subcats in a category, that category's listing will only show the products and not the subcats. This will make navigation different from other categories and may cause confusion for users.

8 Dec 2010, 9:17 PM
#4
chaiavi avatar

chaiavi

New Zenner

Join Date:
Dec 2010
Posts:
51
Plugin Contributions:
0

Post #4 by chaiavi

I understand.

Please, let me elaborate:

I don't want to insert regular products, I want to have articles related to a specific category which has subcategories.

My problem is that the articles which I want to appear in the sidebox only for that category are from type "document general" hence are considered as products, hence cannot be inserted into the category which has subcategories.

can I do it somehow?

Is there any other way?

THE ACTUAL DILLEMA:
How can I show a sidebox with articles only per a specific category and all of its subcategories.

Chaiavi

8 Dec 2010, 9:34 PM
#5
gjh42 avatar

gjh42

Black Belt

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

Post #5 by gjh42

That is no problem. It will take a bit of custom code in the documents sidebox file to filter the display based on the current top product category, but that is not difficult. I can take time to help with that tomorrow, if nobody else has time before then.

First, you would set Configuration > Layout Settings > Split Categories Box -> true, and enable the documents sidebox in Tools > Layout Boxes Controller.
You would probably want to create one "document type" category for each article, or maybe group some articles depending on what organization makes sense.
Then edit the sidebox file to add the filter.

8 Dec 2010, 9:50 PM
#6
gjh42 avatar

gjh42

Black Belt

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

Post #6 by gjh42

I envision a filter starting like```php
$skip_cat = 1;
$current_doc = str_replace('cPath=','',$box_categories_array[$i]['path']);
if(in_array((int)$_GET['cPath'], explode(',','list_of_top_cats,separated_by_commas,and_no_spaces')) and (in_array($current_doc, explode(',','list_of_doc_cats,separated_by_commas,and_no_spaces'))) {
$skip_cat = 0;
} elseif (in_array((int)$_GET['cPath'], explode(',','second_list_of_top_cats,separated_by_commas,and_no_spaces')) and (in_array($current_doc, explode(',','second_list_of_doc_cats,separated_by_commas,and_no_spaces'))) {
$skip_cat = 0;
}

Repeat }elseif(){ lines for as many document groups as needed, and put 

$skip_cat or

into the display filter test.

This may need tweaking, but I think the approach will work.
9 Dec 2010, 9:37 AM
#7
chaiavi avatar

chaiavi

New Zenner

Join Date:
Dec 2010
Posts:
51
Plugin Contributions:
0

Post #7 by chaiavi

Wow, you are totally zenned :-)

I am a new zenner, and most of the things you wrote I didn't understand (although I know some php).

  1. Which file should I edit?

  2. Into which line should I put the code? (I use the latest ZC).

  3. Can you PLEASE add a sentance or two about the logic of what you advise here?

Thank you so much,
I really appreciate it,
Chaiavi

9 Dec 2010, 10:28 AM
#8
gjh42 avatar

gjh42

Black Belt

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

Post #8 by gjh42

/includes/templates/your_template/sideboxes/tpl_document_categories.php

Around line 14, just afterphp for ($i=0;$i<sizeof($box_categories_array);$i++) { add this```php
$show_cat = 0;
$current_doc = str_replace('cPath=','',$box_categories_array[$i]['path']);
if(in_array((int)$_GET['cPath'], explode(',','list_of_top_cats,separated_by_commas,and_no_spaces')) and (in_array($current_doc, explode(',','list_of_doc_cats,separated_by_commas,and_no_spaces'))) {
$show_cat = 1;
} elseif (in_array((int)$_GET['cPath'], explode(',','second_list_of_top_cats,separated_by_commas,and_no_spaces')) and (in_array($current_doc, explode(',','second_list_of_doc_cats,separated_by_commas,and_no_spaces'))) {
$show_cat = 1;
}

if ($show_cat) {//show doc category
and addphp
}// /show

just before```php
    }
      $content .= '</div>';
```at the end of the file to get```php
      $content .= '<br />';
    }// /show
    }
      $content .= '</div>';

You will have to supply the category lists in the places shown.