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

    Default Expanded Category - expand only to subcat1?

    Using Expanded Category 2. I would like to just show category, and 1st subcategory.

    I want all of the other subcategories to be hidden(collapsed).

    Is there a way to do this?

    Thanks.

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

    Default Re: Expanded Category - expand only to subcat1?

    Very easy. The category depth is shown in $cPath, with subcats separated by underscores _ . If it has one underscore, it is a first level subcat, two underscores = second level, etc. You can access that information for each prospective category in the list with
    substr_count($box_categories_array[$i]['path'],'_')

    Find this in /includes/templates/your_template/sideboxes/tpl_categories.php:
    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'],'_') > 1 or
    to get
    PHP Code:
         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 { 

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

    Default Re: Expanded Category - expand only to subcat1?

    Thanks Glenn, your help is invaluable!

  4. #4
    Join Date
    Oct 2007
    Location
    Netherlands
    Posts
    36
    Plugin Contributions
    0

    Default Re: Expanded Category - expand only to subcat1?

    Hiya I not sure of someone still check here but I can not find this Expanded Category 2?

    And I want the Category to always show the submenu (not the products)

    Please tell me where to get this addon!

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

    Default Re: Expanded Category - expand only to subcat1?

    The mod is called Expanded Category List (by Clydejones) and can be found in Downloads.

  6. #6
    Join Date
    Oct 2007
    Location
    Netherlands
    Posts
    36
    Plugin Contributions
    0

    Default Re: Expanded Category - expand only to subcat1?

    Thanks giving it a go but it say it also will list the products

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

    Default Re: Expanded Category - expand only to subcat1?

    Never used it myself so can't comment... I have heard this complaint from other people, but I have also heard from people saying they use it and don't see products in their categories box.

    At any rate, there is another mod called Uncollapsed Categories Tree by fragfutter (hosted on his own site) that reportedly works exactly as you want.
    (It creates a sidebox id of ch_categories, so you can tell by viewing a site's source that they are using this mod.)

  8. #8
    Join Date
    Sep 2006
    Location
    Colorado Springs CO USA
    Posts
    516
    Plugin Contributions
    2

    Default Re: Expanded Category - expand only to subcat1?

    Quote Originally Posted by gjh42 View Post
    Very easy. The category depth is shown in $cPath, with subcats separated by underscores _ . If it has one underscore, it is a first level subcat, two underscores = second level, etc. You can access that information for each prospective category in the list with
    substr_count($box_categories_array[$i]['path'],'_')

    Find this in /includes/templates/your_template/sideboxes/tpl_categories.php:
    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'],'_') > 1 or
    to get
    PHP Code:
         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 { 
    Glenn:
    I added the code but it doesn't seem to make any difference in the display of the category sidebox. I think I'm missing something here. Isn't there some place in the code where I specify how many sub-levels to limit the display? It's probably obvious to experience programmers, but my skills at php are still quite limited.

    My goal is to show only the top level categories and the first sub-level below the top. No products.

    Here is the way I modified the code:

    Code:
     
    // beg mod 2008-01-14 per forum http://www.zen-cart.com/forum/showthread.php?t=83405 post #2 author gjh42 to limit category list to 1 subcategory level.
    //     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)) {
           substr_count($box_categories_array[$i]['path'],'_') > 1 or 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)) {
    // end mod 2008-01-14
    Thanks for any help.

    Ron
    www.aspenshopsonline.com - ZenCart 1.3.9h
    www.wilkssupply.com - ZenCart 1.3.9h
    www.un-du.net - ZenCart 1.3.8a

  9. #9
    Join Date
    Sep 2006
    Location
    Colorado Springs CO USA
    Posts
    516
    Plugin Contributions
    2

    Default Re: Expanded Category - expand only to subcat1?

    gjh42 Glenn:

    I caught the mistake in the previously quoted code. Had the "if" statements misplaced. Here is the correct code, but nevertheless, the problem still exists. I'm showing all category levels and products, but only want two levels.

    Code:
    // beg mod 2008-01-14 per forum http://www.zen-cart.com/forum/showthread.php?t=83405 post #2 author gjh42 to limit category list to 1 subcategory level.
    //     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)) {
           if (substr_count($box_categories_array[$i]['path'],'_') > 1 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)) {
    // end mod 2008-01-14
    // skip if this is for the document box (==3)
    Ron
    www.aspenshopsonline.com - ZenCart 1.3.9h
    www.wilkssupply.com - ZenCart 1.3.9h
    www.un-du.net - ZenCart 1.3.8a

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

    Default Re: Expanded Category - expand only to subcat1?

    The specification of sub-levels happens here:

    substr_count($box_categories_array[$i]['path'],'_') > 1

    In English, it counts the number of times that an _ appears in the string contained in $box_categories_array[$i]['path']. There will be one _ for each level of subcategory, so that's all the technology needed for the spec!
    The whole if() statement skips the category in the list if any of the conditions is true (like the number of _ being > 1).

    As to why it's not working for you, I'll have to check some more.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Expanded category load time?
    By Snaggle in forum General Questions
    Replies: 9
    Last Post: 25 Mar 2012, 02:35 PM
  2. Possible to have only SubCat1 open when clicked?
    By LilleyPadGifts in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 16 Jun 2009, 10:42 PM
  3. expanded category list and 1.3.8
    By jafma in forum All Other Contributions/Addons
    Replies: 4
    Last Post: 4 Sep 2008, 03:17 PM
  4. expanded category
    By tacoma in forum All Other Contributions/Addons
    Replies: 5
    Last Post: 14 Jan 2008, 08:51 AM
  5. Expanded category box
    By DML73 in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 15 Nov 2007, 12:41 AM

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