Page 1 of 3 123 LastLast
Results 1 to 10 of 83

Hybrid View

  1. #1
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: How to hide categories with no active products

    If you guys want to test this the changes are marked in RED:
    /includes/templates/template_default/sideboxes/tpl_categories.php
    Code:
        if ((CATEGORIES_PRODUCTS_INACTIVE_HIDE == 1 && $box_categories_array[$i]['count'] == 0) || 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)
           // skip empty or status off categories
        } else {
          $content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
    
          if ($box_categories_array[$i]['current']) {
            if ($box_categories_array[$i]['has_sub_cat']) {
    /includes/modules/categories_tabs.php
    Code:
      // create link to top level category
      if (CATEGORIES_PRODUCTS_INACTIVE_HIDE == 1 && zen_count_products_in_category((int)$categories_tab->fields['categories_id']) == 0) {
        // skip empty or status off categories
      } else {
        $links_list[] = '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . (int)$categories_tab->fields['categories_id']) . '">' . $categories_tab_current . '</a> ';
      }
      $categories_tab->MoveNext();
    /includes/modules/category_row.php
    Code:
        if (CATEGORIES_PRODUCTS_INACTIVE_HIDE == 1 && zen_count_products_in_category((int)$categories->fields['categories_id']) == 0) {
          // skip empty or status off categories
        } 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'] . '</a>');
    
          $col ++;
          if ($col > (MAX_DISPLAY_CATEGORIES_PER_ROW -1)) {
            $col = 0;
            $row ++;
          }
        }
        $categories->MoveNext();
    /includes/classes/site_map.php
    Code:
          $categories = $db->Execute($categories_query);
          while (!$categories->EOF) {
            if (CATEGORIES_PRODUCTS_INACTIVE_HIDE == 1 && zen_count_products_in_category((int)$categories->fields['categories_id']) == 0) {
              // skip empty or status off categories
            } else {
              $this->data[$categories->fields['parent_id']][$categories->fields['categories_id']] = array('name' => $categories->fields['categories_name'], 'count' => 0);
            }
            $categories->MoveNext();
          }
       }
    Code:
        if (isset($this->data[$parent_id])) {
          foreach ($this->data[$parent_id] as $category_id => $category) {
            if (CATEGORIES_PRODUCTS_INACTIVE_HIDE == 1 && zen_count_products_in_category((int)$categories->fields['categories_id']) == 0) {
              // skip empty or status off categories
              continue;
            }
            $category_link = $parent_link . $category_id;
            $result .= $this->child_start_string;
            if (isset($this->data[$category_id])) {
    Then add the switch to the configuration table via the Tools ... Install SQL Patches ...
    Code:
    INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Categories with Inactive Products Status', 'CATEGORIES_PRODUCTS_INACTIVE_HIDE', '0', 'Hide Categories with Inactive Products?<br />0= off<br />1= on', 19, 30, 'zen_cfg_select_option(array(\'0\', \'1\'), ', now());
    Setting this new setting in the Configuration ... Layout Settings ... for Categories with Inactive Products Status to 0 or OFF will NOT hide the empty Categories or Categories with all Products set to products_status = 0 and setting this to 1 or ON will hide them ...
    Last edited by Ajeh; 25 Nov 2014 at 03:37 AM. Reason: FIX TYPO
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  2. #2
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    391
    Plugin Contributions
    0

    Default Re: How to hide categories with no active products

    It was a legitimate question...not intended to upset anyone. (DivaVocals)

    I still do not see the point of showing categories when no active products are available. It is like having an empty cookie jar on the counter...very frustrating to open it up and see nothing in it when you were expecting to.

    I was not implying that this be a ONE SIZE FITS ALL program...but I have been programming long enough to know that you can option yourself to death if you are not careful.

    I fully appreciate the flexibility of this outstanding program and the people who make it possible! That is why I have followed this program steadily since 1.3.7.

    Thanks for the code Ajeh and for appeasing everyone! You have been a tremendous help indoctrinating me into this program. Novice...maybe, but at least I am looking for ways to improve.

  3. #3
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,021
    Plugin Contributions
    32

    Default Re: How to hide categories with no active products

    Quote Originally Posted by mikeel100 View Post
    It was a legitimate question...not intended to upset anyone. (DivaVocals)

    I still do not see the point of showing categories when no active products are available. It is like having an empty cookie jar on the counter...very frustrating to open it up and see nothing in it when you were expecting to.

    I was not implying that this be a ONE SIZE FITS ALL program...but I have been programming long enough to know that you can option yourself to death if you are not careful.

    I fully appreciate the flexibility of this outstanding program and the people who make it possible! That is why I have followed this program steadily since 1.3.7.

    Thanks for the code Ajeh and for appeasing everyone! You have been a tremendous help indoctrinating me into this program. Novice...maybe, but at least I am looking for ways to improve.
    Not upset.. **SMH** However IMHO this is a place where an option makes sense.. I have clients who have business reasons why they support either option.. glad Ajeh was on the case!
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: How to hide categories with no active products

    You guys are welcome ...

    While I would consider the loss of spiders not finding the Category when disabled and good Category description can help get the Products spidered ... I can also see the desire for this feature ...

    But, to each their own, hence the switch ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,021
    Plugin Contributions
    32

    Default Re: How to hide categories with no active products

    Quote Originally Posted by ajeh View Post
    you guys are welcome ...

    While i would consider the loss of spiders not finding the category when disabled and good category description can help get the products spidered ... I can also see the desire for this feature ...

    But, to each their own, hence the switch ...
    exactly!!!!
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  6. #6
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: How to hide categories with no active products

    Quote Originally Posted by Ajeh View Post
    You guys are welcome ...

    While I would consider the loss of spiders not finding the Category when disabled and good Category description can help get the Products spidered ... I can also see the desire for this feature ...

    But, to each their own, hence the switch ...
    And as provided the switchis currently a simple on/off, it could even be expanded to a multi-level type switch to activate each of the above modifications differently. Though with the number of locations touched I would advise against trying to consider every potentiaal combination of settings as I would aalso guess that some shouldn't be disabled without another...

    Anyways, just thinking about how far a "fix" can go. Like it though seems relatively simple. :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    391
    Plugin Contributions
    0

    Default Re: How to hide categories with no active products

    Made changes as instructed above.

    The Categories Sidebox has no categories showing...I think a closing bracket (}) is missing somewhere but not sure. I have 100,000 products in 2300+ categories with 11 top level categories. None are showing...just the Featured, All, New, and Specials Links.

    Site Map - I get a 500 server error.

    The center box area categories / subcategories appear to be working.

    Category Tabs (top of main page) appears to be working.

    I triple checked the code to make sure it is exactly as you suggested :-)

  8. #8
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: How to hide categories with no active products

    Site Map appears to be working ... did you fix this?

    If so, what was your error?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  9. #9
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    391
    Plugin Contributions
    0

    Default Re: How to hide categories with no active products

    The second correction to the Site Map file is using $categories_tab->field instead of $categories->field.

    Changing it still didn't fix the sitemap issue.

  10. #10
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: How to hide categories with no active products

    Good news ... I did that right for v16 ... Bad news ... I wrote that wrong for what I posted as you discovered ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 
Page 1 of 3 123 LastLast

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

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