Contributions
Activate or inactivate category of catalog
This contributions allows you to display or hide any category or subcategory.
The install is very easy and take a 1 or 2 min.
Expand All / Collapse All
Bug fixed for compatiblity with MySQL 4. If you are using a version of MySQL prior to version 5 you need this correction since in SQL queries version 4 processes NOT before IN rather than IN before NOT as in version 5 under which this contribution was tested. The solution is simply to put parenthesis around the IN operators wherever used in a query to make sure they are processed first regardless of the version of MySQL.
Complete corrected instructions attached. If you've already installed version 1.3 the only changes are that the SQL queries are changed from
and (not p2c.categories_id in (" . implode(',', $hiddencats) . "))
to
and (not (p2c.categories_id in (" . implode(',', $hiddencats) . ")))
in eleven files (one place each in ten files and twice in index.php).
I discovered two more files that needed modification to make sure products are totally hidden when they exist only in a hidden category. Conplete install enclosed but only steps 15 and 16 are new.
I missed a function in catalog/includes/general.php that needs to be updated to correctly count products in a category and only its active sub-categories. Complete instructions are attached but only one has been added:
Find around line 383 in the function tep_count_products_in_category the line that sets $child_categories_query and add the "and status_categ = 1" to it so the line will now read:
$child_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$category_id . "' and status_categ = 1");
The basic contribution as orginally written worked fine to hide categories and their sub-categories in the catalog but it seemed to me like the idea would be hide the products contained in those categories as well. At this the original contribution failed miserably because there are many ways to list a product in osCommerce besides the category listing. Listing by manufacturer or by newest products or performing a search could find products in hidden categories and info boxes like specials, whats_new and reviews can also randomly display such products.
The updated instructions attached use a new configuration variable to determine whether or not products that exist only in hidden categories may be viewed or not. I've also updated the admin side to allow turning the category on or off while creating or editing a category as well as by clicking on the status buttons. The admin category information box will also show whether or not the category will be displayed in the catalog since a category might be set to display but won't because the parent category is hidden.
Instructions for updating a couple of contributions to work properly with this contribution are included at the bottom of the file.
If you are using "Main categories as thubnails on index"
http://addons.oscommerce.com/info/5119
There is a change to do,If you don't and disable a whole categorie "Main categories as thubnails on index" will still show the thumbnail of disabled categorie on your
main page.
To fix it go to catalog/includes/modules/main_cats.php
FIND:
$result = tep_db_query("SELECT * FROM " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd WHERE c.parent_id = '0' AND c.categories_id =
cd.categories_id AND cd.language_id = '" . (int)$languages_id . "' ORDER BY sort_order ");
REMPLACE WITH
$result = tep_db_query("SELECT * FROM " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd WHERE c.parent_id = '0' AND c.status_categ = '1' AND
c.categories_id = cd.categories_id AND cd.language_id = '" . (int)$languages_id . "' ORDER BY sort_order ");
You are done, if you disable a whole categorie thubnail will also dispear from main page.
It works great , thanks, BUT...
The subcategories are hidden in the menu, but when you click in the menu on the level 0 category, the hidden subcategories still appear on the main page because the index.php does it. So you must go in index.php whereever you find TABLE_CATEGORIES and add the "and status_categ = 1" in the query, so only active subcategories are selected from the database and displayed as icons in the main page. I found 5 placed in the index.php where this must be done. There is no sense to add them here because it is easy to find.
I also used "dm_categories.php" add-on (Nate Welch http://www.natewelch.com) instead of the usual categories.php and had to modify only 1 line, the only one where "tep_db_query" appears. Here also must be added "and c.status_categ = 1". I hope it helps.
This contributions allows you to display or hide any category or subcategory.
The install is very easy and take a 1 or 2 min.
Note: Contributions are used at own risk.