Forums / Templates, Stylesheets, Page Layout / Adding Category Counts to Category Images (Rows)

Adding Category Counts to Category Images (Rows)

Locked

Started by dave_1 on 2 Oct 2009, 4:31 AM · Views: 1,122

Results 1 to 1 of 1
This thread is locked. New replies are disabled.
2 Oct 2009, 4:31 AM
#1
dave_1 avatar

dave_1

New Zenner

Join Date:
Oct 2009
Posts:
1
Plugin Contributions:
0

Adding Category Counts to Category Images (Rows)

Hi all.

I'm very new to Zen Cart (and PHP) and have found these forums invaluable while customising the look and feel of a new site, so here I am to try and give a little back :smile:

One modification I wanted was to have the product count suffixed to the Category rows, just like the one in the Category Sidebox. I couldn't find the answer so I decided to roll my own by cutting bits and pieces from around the place.

Works in version 1.3.8a

File to edit: includes/modules/YOUR_OVERLOAD/category_row.php

Change line 40 from:

    $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>');

To:

      $products_in_category = zen_count_products_in_category($categories->fields['categories_id']);
      $content_count = "";

      if (SHOW_COUNTS == 'true') {
        if ((CATEGORIES_COUNT_ZERO == '1' and $products_in_category == 0) or $products_in_category >= 1) {
          $content_count .= ' ' . CATEGORIES_COUNT_PREFIX . $products_in_category . CATEGORIES_COUNT_SUFFIX;
        }
      }

    $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>' . $content_count);

HTH
Dave