Page 1 of 3 123 LastLast
Results 1 to 10 of 28
  1. #1
    Join Date
    Mar 2008
    Posts
    18
    Plugin Contributions
    0

    Have a Drink subcategories only in sidebox main categories top

    I would like to display only the subcategories for a category in a left sidebox. So, basically, you click on a category (horizontal top menu which I have working just fine) and on that specific category page the subcategories are listed in a sidebox and the first subcategory's product items fill up the center column.



    There are a lot of posts related to sideboxes, menu trees etc but after hours of reading through and trying a few I still can't seem to figure it out.

    Any help, links to solutions in the forum, etc. appreciated!

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

    Default Re: subcategories only in sidebox main categories top

    The easiest way to do this is probably by adding a switch that suppresses output of any category that is not current and a subcat.
    Find this line 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
    $current_top = false;
    if ((int)str_replace("cPath=","",$box_categories_array[$i]['path']) == $_GET['cPath']) { //top cat of path is active
    $current_top = true;
    }

    above it, and

    ($current_top == false) or ($box_categories_array[$i]['top'] == 'true') or
    inside it to get
    PHP Code:
    $current_top false;
    if ((int)
    str_replace("cPath=","",$box_categories_array[$i]['path']) == $_GET['cPath']) { //top cat of path is active
    $current_top true;
    }
    if ((
    $current_top == false) or ($box_categories_array[$i]['top'] == 'true') 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 { 
    I haven't tested this yet, so try it and let me know how it works. If it needs tweaking, I'll take care of it.

  3. #3
    Join Date
    Mar 2008
    Posts
    18
    Plugin Contributions
    0

    Default Re: subcategories only in sidebox main categories top

    Hey - that's great!

    I need to add some more subcategories and products to make sure it's working across the board but it appears to work.

    I originally plugged the code into the Categories Dressing tpl_categories.php page that I was working with and it did not work - everything under the top category tab nav disappeared, from the breadcrumbs down. I replaced the tpl_categories with the default and applied your change and this is exactly what I was looking for. Since I don't need the Categories Dressing code I don't mind reverting back.

    I'll be making changes to this as the day progresses but for anyone checking this post the original change stated above supplies a Category Specific - Subcategory Side Box that has the "Categories" title on default blue, a list of the Subcategories, and then "New Products", "All Products" followed by the green bottom. (When I'm done styling it will be slightly different than that).

    Link to test page:
    http://infullfig.com/index.php?main_...&products_id=1

    Thanks!

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

    Default Re: subcategories only in sidebox main categories top

    Glad to see it's working! And it looks really good.

    I noticed something that should be making it malfunction, but it is not malfunctioning...
    The

    if ((int)str_replace("cPath=","",$box_categories_array[$i]['path']) == $_GET['cPath']) {

    compares the first numbers of 'path' (before the _) with the cPath (which may include an _); this should not be equal if you are in a subcategory, but it still works as desired. I'll have to test this to find out exactly why it's working before I want it relied upon.

    The line should read
    PHP Code:
    if ((int)str_replace("cPath=","",$box_categories_array[$i]['path']) == (int)$_GET['cPath']) { 
    so that both values are being truncated the same.

  5. #5
    Join Date
    Mar 2008
    Posts
    18
    Plugin Contributions
    0

    Default Re: subcategories only in sidebox main categories top

    that new change didn't work - everything under the top categories tab disappears completely, from breadcrumbs down. I changed the code back to the original one and it works fine.

    So do you feel the original changes won't work effectively? I don't know enough about PHP to understand exactly how that string of code works.

    Unfortunately, my client wants me to put the site in Under Construction mode until it's finished so if you need to take another look at how it renders let me know and I'll ask permission to post the site with dummy text and images.

    And I wish I could take credit for the site design - it is pretty cool - but it was designed by my client who hands off photoshop file for me to pound into shape using css and html. This is our first ecommerce project.

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

    Default Re: subcategories only in sidebox main categories top

    Curiouser and curiouser...

    The
    str_replace("cPath=","",$box_categories_array[$i]['path'])
    removes the "cPath=" from the beginning of the path item in the array, so the format matches the format of $_GET['cPath'].
    The (int) is a shortcut way to strip the subcategories if any, by type-casting the value as an integer. That might not work the same way on $_GET['cPath'] ...?

    At any rate, if it works, it works.

  7. #7
    Join Date
    Apr 2006
    Posts
    34
    Plugin Contributions
    0

    Default Re: subcategories only in sidebox main categories top

    I would also like to get this working in my site, but when I add the code suggested above, the content disappears from top menu down. I am using v 1.3.8. Any ideas?
    hand screen printed clothing and accessories
    www.wildgardendesign.com

  8. #8
    Join Date
    Apr 2006
    Posts
    34
    Plugin Contributions
    0

    Default Re: subcategories only in sidebox main categories top

    Never mind, I had inserted the code incorrectly. It's working now! yay
    hand screen printed clothing and accessories
    www.wildgardendesign.com

  9. #9
    Join Date
    Jul 2008
    Posts
    15
    Plugin Contributions
    0

    Default Re: subcategories only in sidebox main categories top

    hi gjh42,

    i have to ask because everytime i think i found the solution its for something else.

    the code solution you provide, is that to prevent subcategories from showing up above the items in the middle column underneath the breadcrumbs thing? like ie...

    home::cat1

    subcat1 subcat2 subcat3


    this is the solution i need how to keep those subcategories off and only in the left column box.

    i appreciate it.
    thanks,

    Stoney
    Give a man a light, you help that man for a night. Light him on fire and you help him for the rest of his life.

  10. #10
    Join Date
    Jul 2008
    Posts
    15
    Plugin Contributions
    0

    Default Re: subcategories only in sidebox main categories top

    forget it i found the solution,
    i apologize but since i found it 2 hours ago and then had to rush my son to school i actually forgot the spot in the control panel that did it.

    my bad.
    Give a man a light, you help that man for a night. Light him on fire and you help him for the rest of his life.

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. v153 Always show Subcategories, or different categories in sidebox and top menu?
    By BlackOrchidCouture in forum Setting Up Categories, Products, Attributes
    Replies: 10
    Last Post: 5 Dec 2014, 05:19 PM
  2. Category Sidebox - Only Show Subcategories
    By kidsstuff in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 25 Oct 2010, 07:56 AM
  3. Show only sub-categories when viewing top-categories
    By bthreen in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 21 Feb 2010, 08:28 AM
  4. How to list Subcategories in sidebox only
    By paperthreads in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 13 Feb 2007, 04:40 AM
  5. Underline Only Top Categories In Sidebox
    By ryanp in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 17 Jun 2006, 12:41 PM

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