I have a category with subcategories.
Is there any way of adding products to that category?
Chaiavi
I have a category with subcategories.
Is there any way of adding products to that category?
Chaiavi
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
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.
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
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.
I envision a filter starting likeRepeat }elseif(){ lines for as many document groups as needed, and putPHP Code:$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;
}
$skip_cat or
into the display filter test.
This may need tweaking, but I think the approach will work.
Last edited by gjh42; 8 Dec 2010 at 10:55 PM.
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
/includes/templates/your_template/sideboxes/tpl_document_categories.php
Around line 14, just afteradd thisPHP Code:for ($i=0;$i<sizeof($box_categories_array);$i++) {
and addPHP Code:$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
just beforePHP Code:}// /show
at the end of the file to getPHP Code:}
$content .= '</div>';
You will have to supply the category lists in the places shown.PHP Code:$content .= '<br />';
}// /show
}
$content .= '</div>';
Last edited by gjh42; 9 Dec 2010 at 11:32 AM.