[HACK] An Easy Way To Manage Your Side-Category List

Modules, Add-ons and custom code that's more than just a quick hack or Mod.
Post Reply
CharlieFoxtrot
Confirmed
Confirmed
Posts: 413
Joined: Sun Aug 09, 2009 1:23 pm

[HACK] An Easy Way To Manage Your Side-Category List

Post by CharlieFoxtrot »

Problem: The default way in which the Side-Category/Subcategory menu is presented can often make for some exceedingly long and unwieldy menu displays. ~ I needed a simple way to get this under control. Again... something SIMPLE that didn't require a lot of PHP or CSS or HTML or JavaScript modifications.

Analysis: After reviewing my list of categories and subcategories, I saw that it was not absolutely necessary to display many of the sub-categories in the Side-Category Menu. ~ However... those sub-categories ARE necessary to have because they help to organize the products and make things easier to find.

Goal: Find a way to trim-down the Side-Categories menu (by removing selected sub-categories)... but STILL have those sub-categories exist, so that customers can access them, and so that the products inside are neatly organized.

SOLUTION: The steps described below will allow you to "hide" sub-categories (ie: prevent them from being displayed in the Side-Categories menu) yet they are still visible and easily accessed from within the top-level category.

As always... MAKE BACKUPS, TEST BEFORE GOING LIVE, etc etc.

VERSION USED HERE: ISC 4.07
FILE TO EDIT: /includes/display/SideCategoryList.php

FIND: (near line 65)

Code: Select all

$catName = isc_html_escape($subCat['catname']);
INSERT ABOVE THAT LINE:

Code: Select all

// Check to see if the category name begins with a dash
// If so, skip it... and move on to the next item in the list.
if (substr($subCat['catname'], 0, 1) == "-") {continue;}
(The comments are optional... but if you need to make changes in the future, it will be easy to see-understand-remember the changes you made.)

Upload the file to your server and test to make sure your Side-Categories menu still displays properly. (Assuming that none of your current category names begin with a dash "-", then you should notice no changes.)

TO "HIDE" SUB-CATEGORIES:

From the Admin menu, select "Products" from the menu-tabs... then select "Product Categories" from the drop-down menu.
Next, find a sub-menu that you want to hide... click "Edit" on its row.
Rename the sub-menu item by adding a dash and a space just before it... save your changes.

TEST YOUR CHANGES:

-- Verify that the renamed sub-menu does not appear in the Side-Categories list.

-- Click the parent category of the newly hidden item... and the renamed sub-category should be displayed in the sub-category block at the top of the page.

NOTES: You can use any leading-character to flag the sub-categories that you want to hide. Just make the appropriate changes to your PHP code. (I chose to use a dash because it was fairly unobtrusive and wouldn't cause customers any confusion.)

POSSIBLE ISSUE: Here is one thing to watch out for (but that I have not tested because my sub-category levels are only one layer deep.

o What happens if the hidden sub-category ALSO has child sub-categories of its own?
o What happens if those sub-sub-categories are not renamed and hidden using this method?
o Will they be displayed anyway? If so, how will this affect the Side-Category structure?


Good Luck! ~ Post any improvements or corrections here.
meules
Confirmed
Confirmed
Posts: 95
Joined: Wed Jun 17, 2009 8:56 pm
Location: NL

Re: [HACK] An Easy Way To Manage Your Side-Category List

Post by meules »

Great!! This is a simple little piece of code that's very usefull for my site. Is it also possible to hide the subcats and below have a link which say "more"? Like this:

main cat
- subcat 1
- subcat 2
- subcat 3
- more

My customers can shop by color but I have a list of 26 different colors. You can imagine how long this list will be if I show them all in the menu. So what I want to archieve is that the colors most used are displayed in the menu, and the colors which are seasonal related go under the link "more". Is this possible?

Anyway thanks for the hack...
ISC v6
CharlieFoxtrot
Confirmed
Confirmed
Posts: 413
Joined: Sun Aug 09, 2009 1:23 pm

Re: [HACK] An Easy Way To Manage Your Side-Category List

Post by CharlieFoxtrot »

meules wrote:Great!! This is a simple little piece of code that's very usefull for my site. Is it also possible to hide the subcats and below have a link which say "more"?
Okay... go here: http://www.interspired.net/forum/viewto ... f=12&t=233 :mrgreen:
ISC 4.0.7

"... and let's be honest that whole "by design" thing is getting old too."
Post Reply