New Zenner
- Join Date:
- Dec 2010
- Posts:
- 51
- Plugin Contributions:
- 0
Post #1 by chaiavi
I have a category with subcategories.
Is there any way of adding products to that category?
Chaiavi
Started by chaiavi on 8 Dec 2010, 3:22 PM · Views: 1,250
New Zenner
I have a category with subcategories.
Is there any way of adding products to that category?
Chaiavi
Black Belt
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:
Black Belt
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.
New Zenner
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
Black Belt
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.
Black Belt
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.
New Zenner
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).
Which file should I edit?
Into which line should I put the code? (I use the latest ZC).
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
Black Belt
/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.
Tell staff why this post should be reviewed.