Zen Cart Logo
Forums / General Questions / move Sub Categories Count

move Sub Categories Count

Locked

Views: 4,558

Results 21 to 23 of 23
This thread is locked. New replies are disabled.
29 Mar 2008, 12:43 PM
#21
wmorris avatar

wmorris

Totally Zenned

Join Date:
Aug 2007
Location:
Amarillo, Tx
Posts:
1,682
Plugin Contributions:
0

move Sub Categories Count

I have put the code in where you selected here :

<?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);

// ################################################## ################
$myCatID = substr($cPath_new, -3);
// $categories->fields['products_name'] = zen_get_products_name($categories->fields['products_id']);

$check_categories = $db->Execute("select products_id from " . TABLE_PRODUCTS . " where
master_categories_id = '".$myCatID."'");
if ($check_categories->RecordCount() > 0) {
// create number here
$recordCount = $check_categories->RecordCount();
}

$countContent = CATEGORIES_COUNT_PREFIX . $recordCount . 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'].' '.$countContent.'</a>');
// ################################################## ################
$col ++;


    //    $categories->fields['products_name'] = zen_get_products_name($categories->fields['products_id']);

    $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();
  }
}
?>

and I am getting double listings.

29 Mar 2008, 12:59 PM
#22
digitechstop avatar

digitechstop

New Zenner

Join Date:
Oct 2006
Posts:
6
Plugin Contributions:
0

Re: move Sub Categories Count

you didn't put it in the right place. Can you see where you have col++ written twice at the bottom of the file? Your paste should have covered the second col++, replacing it with the first.

I've noticed some other issues and I'll also perfect the category choosing thing. I'll post the entire file here for you in a couple of hours.

29 Mar 2008, 1:57 PM
#23
digitechstop avatar

digitechstop

New Zenner

Join Date:
Oct 2006
Posts:
6
Plugin Contributions:
0

Re: move Sub Categories Count

problem solved: works perfectly on my site (http://www.digitechstop.com)

content of includes/modules/category_row.php:

<?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); // explode the path to extract number of levels in category tree $fullCatID= explode("_",$cPath_new); // take the final level because it is the category whose contents are being displayed at current time $myCatID = $fullCatID[sizeof($fullCatID)-1]; // fixer for when category is empty and not filled with subcategories // check to see if myCatID is a parent category $parentCheckQuery = "select parent_id from " . TABLE_CATEGORIES . " where parent_id = '".$myCatID."'"; $check_parent = $db->Execute($parentCheckQuery); if ($check_parent->RecordCount() > 0) { // it is a parent, so do not show total here $countContent = ''; } else { // $categories->fields['products_name'] = zen_get_products_name($categories->fields['products_id']); $catQuery = "select products_id from " . TABLE_PRODUCTS . " where master_categories_id = '".$myCatID."'"; $check_categories = $db->Execute($catQuery); if ($check_categories->RecordCount() > 0) { // create number of items in category here $recordCount = $check_categories->RecordCount(); $countContent = CATEGORIES_COUNT_PREFIX . $recordCount . CATEGORIES_COUNT_SUFFIX; } else {$countContent = CATEGORIES_COUNT_PREFIX . '0' . CATEGORIES_COUNT_SUFFIX;} } // end else of parent check $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'].' '.$countContent.'</a>'); $col ++; if ($col > (MAX_DISPLAY_CATEGORIES_PER_ROW -1)) { $col = 0; $row ++; } $categories->MoveNext(); } } ?>