Results 1 to 10 of 83

Threaded View

  1. #39
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    387
    Plugin Contributions
    0

    Default Re: How to hide categories with no active products

    Quote Originally Posted by Ajeh View Post
    It sounds like what you really want to do is not show the Empty Categories in the middle of the page ...

    To do that, you can edit the module:
    /includes/modules/category_row.php

    and add the code in RED:
    Code:
    // bof: hide empty categories
    if (zen_count_products_in_category($categories->fields['categories_id']) == 0) {
      // skip empty category
    } else {
        $list_box_contents[$row][$col] = array('params' => 'class="categoryListBoxContents"' . ' ' . 'style="width:' . $col_width . '%;"',
                                               'text' => '<a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . zen_image(DIR_WS_IMAGES . $categories->fields['categories_image'], $categories->fields['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br />' . $categories->fields['categories_name'] . ' ' . $countContentProduct . '</a>');
    }
    // bof: hide empty categories
    
        $col ++;
        if ($col > (MAX_DISPLAY_CATEGORIES_PER_ROW -1)) {
    NOTE: That other code I gave you is not a good solution at all for the Category Tabs, so I would remove it ...
    Actually, I want to hide subcategories where all products are inactive and subcategories where no products are in them.

    Didn't work...it hid the empty categories but it also hid some categories with products active. It also left random blank areas where categories should be.

    The end of my categories_tab page code looks different than yours. . ' ' . $countContentProduct is missing right before </a>.

    PHP Code:
    $categories->fields['categories_name'] . '</a>');

        
    $col ++;
        if (
    $col > (MAX_DISPLAY_CATEGORIES_PER_ROW -1)) {
          
    $col 0;
          
    $row ++;
        }
        
    $categories->MoveNext();
      }

    I don't know if that has anything to do with it since I'm no guru on this code.

    Thanks again.
    Last edited by mikeel100; 31 Jul 2014 at 04:06 AM. Reason: Explaination...

 

 

Similar Threads

  1. v150 how do i hide sub categories with no products listed
    By alibaba99 in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 28 Jan 2017, 06:19 PM
  2. Hide Categories with 0 Products
    By Semenek in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 4 Sep 2010, 05:44 PM
  3. Hide categories/subcategories with no products
    By earthone in forum Basic Configuration
    Replies: 0
    Last Post: 22 Jul 2010, 09:38 PM
  4. Active products in categories box
    By ouxly40 in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 26 Sep 2007, 11:46 AM
  5. How to hide sub-categories with no active products?
    By donplay in forum Setting Up Categories, Products, Attributes
    Replies: 5
    Last Post: 29 Aug 2007, 08:20 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