Zen Follower
- Join Date:
- Jun 2008
- Posts:
- 111
- Plugin Contributions:
- 0
Views: 3,253
Zen Follower
Black Belt
I just loaded it in my fresh 1.3.9g test site and it worked fine. It does list counts of 0, so a bit more tweaking is in order. I'll post the file so you don't get snippet copy/paste issues.
Check your template folders - do you already have a version of that file? if so, you really need to merge the two carefully.
Black Belt
/includes/modules/your_template/category_row.php```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 $ category product counts gjh42 2010-09-30 (lines 33, 40) */ 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']); $cat_count = zen_count_products_in_category($categories->fields['categories_id'])? '<span class="catCount">' . CATEGORIES_COUNT_PREFIX . zen_count_products_in_category($categories->fields['categories_id']) . CATEGORIES_COUNT_SUFFIX . '</span>': '';// // strip out 0_ from top level cats $cPath_new = str_replace('=0_', '=', $cPath_new); // $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'] . $cat_count . '</a>');// $col ++; if ($col > (MAX_DISPLAY_CATEGORIES_PER_ROW -1)) { $col = 0; $row ++; } $categories->MoveNext(); } } ?>
Zen Follower
I tried applying the differenace in this code which was one line
"$cat_count = zen_count_products_in_category($categories->fields['categories_id'])? '<span class="catCount">' . CATEGORIES_COUNT_PREFIX . zen_count_products_in_category($categories->fields['categories_id']) . CATEGORIES_COUNT_SUFFIX . '</span>': '';//"
and then started up my online shop and found no difference - the counts are only showing up within the Category Box and not when the Categories are displaying in the middle section - they just show the category name but no counts next to them.
Am I doing something wrong?
Black Belt
You got the statement where the count is figured out; there is also a small addition to the end of the $list_box_contents statement:
. $cat_count
This is what causes the count to display.```php
$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'] . $cat_count . '</a>');//
Zen Follower
Okay I copied and pasted the code - dumb question - now how do I turn on the categories to display in the middle section?:cry:
Zen Follower
THANK YOU FOR THIS CONTRIBUTION!!!! I got it to work for me. :clap: :clap:
Zen Follower
Okay like what I see with the exception of one thing - the categories with zero counts are showing up even though I turn that feature off? Any suggestions?
Zen Follower
I guess while I'm at it - is there a way to control the sort order of the categories displaying in the middle section?
Black Belt
I guess while I'm at it - is there a way to control the sort order of the categories displaying in the middle section?
When you created the cats in the admin did you give them a sort order?
Black Belt
The line you posted to show what you added has the test to show only positive counts (from the complete file post). If it is not working as desired, copy the whole file into your template folder. It does work correctly in my test site.
Changing the sort order of the categories is a whole different matter. You can set that in admin > Catalog > Categories/Products.
Zen Follower
gjh42:
I just loaded it in my fresh 1.3.9g test site and it worked fine. It does list counts of 0, so a bit more tweaking is in order. I'll post the file so you don't get snippet copy/paste issues.
Check your template folders - do you already have a version of that file? if so, you really need to merge the two carefully.
thanks glenn. i'll try this new code today.
i will also check for a duplicate template file, that may be the problem, but i'm not sure. i'm only just now starting to really get the override part of template override systems. and... i keep f'ing up my php the more i futz with my site.
of course, upgrading to 1.3.9 is on my to-do list before i show my shop to the world, but haven't done it yet. all in good time...
xoxo to the bardo clan!
Black Belt
When you do upgrade, you won't have to worry about this mod - the file hasn't changed in years 2006-08-06 so there will be no need to winmerge it.
Did you have a copy of the file in your custom template already when you copy/pasted the code into it? Or did you put a fresh copy of /includes/modules/category_row.php in /includes/modules/your_template/?
The Bardos are all good - Billy was tickled to hear we're talking here:)
Zen Follower
Yes and I tried playing around with the options starting with 0-3 and they didn't seem to make any difference? Got any ideas?
Black Belt
I tried playing around with the options starting with 0-3 and they didn't seem to make any difference?
What options?
Black Belt
Options for category sort order? Make them all unique, and in the order you want them to display. It is a good idea to count by 10s, so you can easily insert a new one in the middle if you ever need to, without renumbering all of them.
10 20 30 40 ...
Zen Follower
glenn, thanks so much.
i think it was a duplicate template issue. your complete page code is now working. my diff tool showed me some text blobs that seemed no different to me, so i punted and just replaced mine with yours. where can i find a completely clean copy of the original version... do i have to extract all the files again? maybe grab it from the 1.3.9 upgrade?
blessings!
Black Belt
You should have a clean version of the file in /includes/modules/category_row.php; but if not, I only added one line and changed one line of code, as the note in the top comments says:
@version $Id: category_row.php 4084 2006-08-06 23:59:36Z drbyte $
category product counts gjh42 2010-09-30 (lines 33, 40)```php
$cat_count = zen_count_products_in_category($categories->fields['categories_id'])? '<span class="catCount">' . CATEGORIES_COUNT_PREFIX . zen_count_products_in_category($categories->fields['categories_id']) . CATEGORIES_COUNT_SUFFIX . '</span>': '';//added line
'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'] . $cat_count . '</a>');//changed line
Zen Follower
glenn,
i want to drop the category count down with a br tag. i've tried a few things, all akin to this:
$cat_count = zen_count_products_in_category($categories->fields['categories_id'])? '<span class="catCount">'[B] . '<br />' . [/B]CATEGORIES_COUNT_PREFIX . zen_count_products_in_category($categories->fields['categories_id']) . CATEGORIES_COUNT_SUFFIX . '</span>': '';
but my greenness at php is showing...
Black Belt
fontaholic:
i want to drop the category count down with a br tag
admin > config > layout settings > Categories Separator between the Category Name and Count >
Default
->
Change to
<br/> ->
Tell staff why this post should be reviewed.