Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Dec 2007
    Posts
    9
    Plugin Contributions
    0

    Default Hide top category - Skip to subcategories

    Hi,

    Is there a way to hide top categories and skip to subcategories in the front-end of the site? Here's an example:

    Backend categories:

    > Cats
    > Cat food
    > Cat toys
    > Dogs
    > Dog food
    > Dog collars

    Front end categories (what I want):

    > Cat food
    > Cat toys
    > Dog food
    > Dog collars

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Hide top category - Skip to subcategories

    This is easy to do, and has been discussed here before.

    In /includes/templates/your_template/sideboxes/tpl_categories.php, find this
    PHP Code:
         if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
            
    // skip if this is for the document box (==3)
          
    } else { 
    and add

    substr_count($box_categories_array[$i]['path'],'_') = 0 or

    to the if test to get this
    PHP Code:
    // subcat limit 2007-12-20
          
    if (substr_count($box_categories_array[$i]['path'],'_') = or zen_get_product_types_to_category($box_categories_array[$i]['path']) == or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
            
    // skip if this is for the document box (==3)
          
    } else { 
    The number of underscores in $box_categories_array[$i]['path'] indicates the category level, with 0 being a top cat.

    The code can also be used to hide lower level subcats, with

    $box_categories_array[$i]['path'] > 1


    Your subcats will still display as subcats, though (with indents etc.); is there a reason you need to keep cats and dogs separate if you don't want to show them as top-level groupings?

    You would need the Expanded Category List mod from Downloads in order to show all of the subcats and not just the ones in the current selected top cat.
    Last edited by gjh42; 24 Dec 2007 at 08:22 PM.

  3. #3
    Join Date
    Dec 2007
    Posts
    9
    Plugin Contributions
    0

    Default Re: Hide top category - Skip to subcategories

    Thanks.

    I add the suggested line, but with == instead of = as I was getting a blank page with only =. Is this ok?

    One reason behind this question is to handle future product expansion. Let's say I sell pet products and have these products at the moment:

    Dog food
    Dog clothes
    Dog collars
    Dog beds
    Cat food
    Cat beds
    Bird food


    If you plan to have more products in the future, it would be wise to have these top level categories: Dog, Cat, Bird. That way, when you manage your products, things are neatly organized. However, because there's not a lot of sub-categories, you may want for save time for your shoppers and immediately skip to second level categories, at least until you have enough subcategories to justify making a top level selection first.

    I think it could be useful to have this in the admin backend so you can hide categories on an individual basis. Like if you have tons of dog categories but little for other animals, you could elect to hide all top categories except the dog one, like so:

    Dog supplies
    Cat food
    Cat beds
    Bird food

    It's sort of separating the way you organize inventory (which doesn't consider user experience) VS shopping categories (you have to consider user experience)

    I'll have a look at the at the module you reference, thank you.

  4. #4
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Hide top category - Skip to subcategories

    Yes, the == is correct. I realized after posting that it was still coded for the original function of hiding lower level subcats (> 1) so rewrote in a hurry.

    You might want what at least one other member has done recently, which is to use the categories-tabs menu (horizontal bar at top) for the top categories, and restrict the sidebox menu to only subcats of the current top cat. If you get sub-subcats, having them all open all the time could be untidy, and having all first level subcats open but only the active sub-subcats would be another level of coding complexity.

    And making all of this individually selectable in admin would be several more levels of work, requiring good PHP and probably mySQL skills and a thorough knowledge of Zen Cart's inner workings.

  5. #5
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Hide top category - Skip to subcategories

    Another thing you might consider is organizing your structural categories the same way you want them viewed, such as making cat and bird items top cats since there are few of them, and dog items subs under one top. Categories are flexible and their organization can be changed easily, so you could always make a top category for Cat Supplies later and move Cat Food and Cat Beds and Cat Whatever etc. under that when the variety warrants.

    And it won't really benefit you to have top categories to hold all dog/cat/etc. items until you have a lot of subcats, since you can assign sort order to each category and keep all dog categories together in the admin menu. Then they will be easier for you to access - one less level to click through for maintenance.
    Last edited by gjh42; 24 Dec 2007 at 11:13 PM.

  6. #6
    Join Date
    Nov 2005
    Location
    Vancouver, Canada
    Posts
    151
    Plugin Contributions
    0

    Default Re: Hide top category - Skip to subcategories

    Quote Originally Posted by gjh42 View Post
    You might want what at least one other member has done recently, which is to use the categories-tabs menu (horizontal bar at top) for the top categories, and restrict the sidebox menu to only subcats of the current top cat.
    Hi:

    I'm using v1.3.8a and I'm looking to do exactly what you stated above. the website in questions is here

    If I have no sub-cats, the tabs will display all the products. I recently moved the products into sub-cats. now when I click on the category tab nothing shows up on the main page. I also want to restrict the right hand menu to only show sub categories.

    This is the first time I'm modifing to this extent. i'm not a coder, but I can follow instructions if properly explained. Can you tell me where I can find the post that shows how to do what I want? or perhaps advise me as to how I should proceed?

    thank you.

  7. #7
    Join Date
    Jan 2009
    Posts
    5
    Plugin Contributions
    0

    Default Re: Hide top category - Skip to subcategories

    I'm trying to get my main categories with subcategories listed, but when I try that code (with two ==), I get NO categories at all. One of my main categories has subcategories, but the others do not.

    So how do I change this to include main categories and subcategories? I also have 4 categories right now, but only 3 are visible.

    Help? Thanks!
    www.topreservethenation.com

  8. #8
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Hide top category - Skip to subcategories

    To get the functionality you want, you first need to install an expanded categories mod that will show all categories all the time. Then you can use the code to limit what displays.

    I recommend fragfutter's Uncollapsed Categories Tree (available from his personal site) for this, as it is compatible with the existing tpl_categories.php file.

  9. #9
    Join Date
    Dec 2009
    Location
    Sarajevo
    Posts
    80
    Plugin Contributions
    0

    Default Re: Hide top category - Skip to subcategories

    This thread was very helpeful to me because I need same thing on my website and I achieved it thanks to Glenns code bellow
    Code:
    // subcat limit 2007-12-20
          if (substr_count($box_categories_array[$i]['path'],'_') = 0 or 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)) {
            // skip if this is for the document box (==3)
          } else {
    but in my case I dont need subcategories to show any further subcategories. To explain what I want to achieve here's the example:

    -----------------------------------------------
    THIS IS HOW IT LOOKS LIKE NOW:
    -----------------------------------------------

    MAZDA (1st subcategorie level)
    - mx (2nd subcategorie level)
    -- 2005 year (3rd subcategorie level)
    -- 2006 year
    -- 2007 year
    - cx
    - rx
    MERCEDES
    - c
    - e
    - s
    MITSUBISHI
    - lancer
    - pajero
    - l200


    -----------------------------------------------
    THIS IS HOW I NEED IT:
    -----------------------------------------------


    MAZDA (1st subcategorie level)
    MERCEDES
    MITSUBISHI

    Any help is wellcome, thanks!
    Last edited by adi2009; 1 Feb 2010 at 03:18 PM.

  10. #10
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Hide top category - Skip to subcategories

    You can do this easily by editing a define in Categories Dressing, which I believe you are using now. Post in the support thread preferably with a link to see your site, and I will guide you.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Hide Toplevel category but show subcategories
    By JDAhlbom in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 13 Dec 2011, 09:55 PM
  2. Displaying Subcategories at the top of Category Pages
    By kabbink in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 26 Mar 2008, 02:07 AM
  3. Top Category image size with Subcategories
    By ellivir in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 31 Oct 2006, 10:36 AM
  4. howto show always Top and Subcategories in the category box?
    By wflohr in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 31 May 2006, 06:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR