Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2011
    Location
    guernsey , uk
    Posts
    39
    Plugin Contributions
    0

    Default how do i hide sub categories with no products listed

    i have just launched my new website www.iwantasmartphone.com
    which has lots of sub categories. at present some of these sub categories have no products listed within them, but in the future, when i bulk up load new products using easypopulate, there will be products added into these sub categories.

    for now, rather than manually disabling each category, which would then need to be manually reactivated in the future, is there a script that can be added anywhere on my php files, which would allow to only show on the side index, those categories and sub categories that have products listed (and therefore automatically hide those categories/sub categories with <1 product listed)

    Any help would be very much appreciated, as i am working through launching seventeen new websites all using the allysa rounded template, and this would become a standard script i could apply to them all.

    thank you
    mark

  2. #2
    Join Date
    Mar 2011
    Location
    guernsey , uk
    Posts
    39
    Plugin Contributions
    0

    Default Re: how do i hide sub categories with no products listed

    i have just come across another posting that has a similar solution, but cannot find where on my cart php structure to implement it as it refers to a "category_row.php" file, which is not present on my template.

    if anyone can adjust this scfript and let me know which file to apply this to, i would be so grateful

    <?php
    /**
    * index category_row.php
    *
    * Prepares the content for displaying a category's sub-category listing in grid format.
    * Once the data is prepared, it calls the standard tpl_list_box_content template for display.
    *
    * @package page
    * @copyright Copyright 2003-2006 Zen Cart Development Team
    * @copyright Portions Copyright 2003 osCommerce
    * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
    * @version $Id: category_row.php 4084 2006-08-06 23:59:36Z drbyte $
    */
    if (!defined('IS_ADMIN_FLAG')) {
    die('Illegal Access');
    }
    $title = '';
    $num_categories = $categories->RecordCount();

    $row = 0;
    $col = 0;
    $list_box_contents = '';
    if ($num_categories > 0) {
    if ($num_categories < MAX_DISPLAY_CATEGORIES_PER_ROW || MAX_DISPLAY_CATEGORIES_PER_ROW == 0) {
    $col_width = floor(100/$num_categories);
    } else {
    $col_width = floor(100/MAX_DISPLAY_CATEGORIES_PER_ROW);
    }

    while (!$categories->EOF) {
    if (!$categories->fields['categories_image']) !$categories->fields['categories_image'] = 'pixel_trans.gif';
    $cPath_new = zen_get_path($categories->fields['categories_id']);

    // strip out 0_ from top level cats
    $cPath_new = str_replace('=0_', '=', $cPath_new);

    // PM ADDED
    $products_in_category = zen_count_products_in_category($categories->fields['categories_id']);

    // PM ADDED The Category if product count > 0
    if ($products_in_category > 0) {
    $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();
    }
    }
    ?>

  3. #3
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    383
    Plugin Contributions
    0

    Default Re: how do i hide sub categories with no products listed


 

 

Similar Threads

  1. How to hide categories with no active products?
    By tj1 in forum Setting Up Categories, Products, Attributes
    Replies: 82
    Last Post: 6 May 2020, 09:27 PM
  2. How can I hide sub sub categories of a category in left sidebox?
    By X-Bumble in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 15 Feb 2012, 07:11 PM
  3. Hide Categories with 0 Products
    By Semenek in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 4 Sep 2010, 05:44 PM
  4. Displaying sub-categories and products with categories
    By andytho in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 15 Jul 2010, 11:16 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