Just so you know, I did copy /includes/templates/templates_default/sideboxes/tpl_categories.php
and place it in my customized folder... /includes/templates/MY_FILES/sideboxes/tpl_categories.php
Printable View
Just so you know, I did copy /includes/templates/templates_default/sideboxes/tpl_categories.php
and place it in my customized folder... /includes/templates/MY_FILES/sideboxes/tpl_categories.php
I forgot ... you probably have set this to false:
Turn that to true ...Quote:
Show Category Counts
Count recursively how many products are in each category
Now, starting with a clean:
/includes/templates/templates_default/sideboxes/tpl_categories.php
using your templates and overrides make the following changes in RED:
Then change the code:Code: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 or $box_categories_array[$i]['count'] == 0)) {
// skip if this is for the document box (==3)
} else {
$content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
So while you say show the counts in configuration ... you will not show the counts but will still gather the counts so that categories with 0 Products will not show ...Code:if (false && SHOW_COUNTS == 'true') {
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;
}
}
Does this work better for you?
Where, in zencart, are the calculations done for making the, ## of ## active, display next to the green/red buttons in admin/categories? That is the info I need to make a simple MySQL code work for this issue.
I've posted the post below at stackoverflow to try and help find a solution as well...http://stackoverflow.com/questions/1...egory-are-zero
First off, let me say I am a NOVICE MySQL programmer. I appreciate any help I can get.
I am trying to update a record value in one table where the count of records in a separate table are equal to the count of records in another table where a certain criteria is met.
In real language: Within a specific category, if all of the products_status, in table products, are set to 0 (not active), then I want to set the category_status, in table category, to 0 (hidden).
I'll explain my thought process after I give you a little background info.
The relevant parts of my categories table are: categories_id (unique and autoincremented) categories_status (0 or 1) parent_id
The relevant parts of my products table are: products_id (autoincremented) products_status (O or 1) master_categories_id (I believe it is linked to the categories_id column n the categories table)
The products_to_categories table has two columns: products_id categories_id
Now, this is what I am attempting:
1. Go to the first record of categories.categories_id and set that as a variable (CategorySearchID).
2. Go to products.master_categories_id and count the number of records that match the CategorySearchID and set that to a variable (CategorySearchIDCount). This gives the total number of products in that CategorySearchID.
3. Go to products.products_status and count all records that have a product_status of 0 where the CategorySearchID is a match.
4. Compare the counts in step 2 and 3. If they are equal, the categories.category_status for the current CategorySearchId will be set to 0 (hidden).
5. Finally, I need a loop that will search through all categories.category_id (CategorySearchID) and do the count comparisons and status updates in steps 2, 3 and 4.
I have tried dozens of combinations of the following code but keep getting errors. I can get some of the individual element of the code to work but I can't seem to tie them all together.
For example:
UPDATE DATABASE.categories SET categories_status = 0
Sets all category_status' to 0 successfully
SELECT COUNT(products_id) FROM products WHERE products_status=0
Finds all of the products_status' set to 0 and returns the number in a temporary table.
AND parent_id != 0;
Prevents top level categories from being set to hidden
I'm not going to bore you with all of the combinations I've tried.
Again, I really would appreciate any help!
Mike
In the Class category_tree.php the counts are made and the tree made for the sidebox ...
With only the changes that I posted, for only the tpl_categories.php file, Only Categories that contain Active Products are showing ... NOTE: you need the Category Counts turned on in the settings to know which Categories to show or exclude, but the counts will still be hidden based on the code changes that I posted ...
Have you additional changes that might be causing this to not work for you?
Your a life saver and a genius Ajeh! Thanks!
I believe this will work! No need to manually change CATEGORY buttons from green to red now!
It's not affecting searches neither!
I can sleep tonight...LOL.
I'll post this answer into the other threads I ran across where nobody found a solution to.
Thanks for the update that this did work for you ... :smile:
Always a pleasure ... remember the Zen Cart Team when you are rich and famous! :cool: