Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Category Descriptions displayed along-side Category Images.

Category Descriptions displayed along-side Category Images.

Locked

Views: 6,507

Results 1 to 19 of 19
This thread is locked. New replies are disabled.
18 Sep 2006, 1:42 AM
#1
roadhead avatar

roadhead

New Zenner

Join Date:
Feb 2006
Posts:
11
Plugin Contributions:
0

Category Descriptions displayed along-side Category Images.

I'd like to be able to display the Category Description of a Sub-Category next to the image and link for that Sub-Category.

I'm running Zen Cart 1.3.0.2

For example, the Main Category is Shooting Glasses, with two manufacturers as Sub-Categories underneath it. When you view the Shooting Glasses category, there are my images for the Sub-Categories, and the description for the Shooting Glasses category, but I would like to be able to display my sub-category descriptions next to the image-link that leads to that category.

I've been playing around with /templates/mytemplate/templates/tpl_modules_category_icon_display.php

and thought I had it when I added the line

echo zen_get_category_description(zen_get_products_category_id((int)$_GET['products_id']), $_SESSION['languages_id']);

But that was a no go.

28 Sep 2006, 3:26 PM
#2
peanut77 avatar

peanut77

Zen Follower

Join Date:
Feb 2005
Posts:
266
Plugin Contributions:
0

Re: Category Descriptions displayed along-side Category Images.

Hi Roadhead

I'm looking to do this too - will have a shot and let you know if I get anywhere.

29 Sep 2006, 8:36 AM
#3
peanut77 avatar

peanut77

Zen Follower

Join Date:
Feb 2005
Posts:
266
Plugin Contributions:
0

Re: Category Descriptions displayed along-side Category Images.

I don't think the category_icon_display.php is the one - I've been messing about and the mistakes I've made affect the product page rather than the sub category page.

29 Sep 2006, 9:15 AM
#4
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: Category Descriptions displayed along-side Category Images.

I am am currently adding some lines in category_row.php (modules/) to add the descriptions:

  $categories->fields['categories_description'] = zen_get_category_description($categories->fields['categories_id'], $_SESSION['languages_id']); // move to reduce queries?
  $list_box_contents[$row][$col]['categories_description'] = $categories->fields['categories_description']; 

I think the first line is a bit of a waist, because it adds more queries than needed to the script, but I haven't had time yet to find out where the queries are done and to move it to that file. Not that it really is a problem, but it would be nice to optimize if possible.

Anyway, after the above addition is made, you can output the categories_description in the template file (I am not 100% if it's the same file in every version but in my case I think it is tpl_columnar_display.php). Maybe I will post more when it's ready.

29 Sep 2006, 9:20 AM
#5
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: Category Descriptions displayed along-side Category Images.

Or you can add it to the output of the module itself of course, to keep things simple, and thus edit only one file.

(although the output of things like these actually belong in the template files tmho)

29 Sep 2006, 9:26 AM
#6
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: Category Descriptions displayed along-side Category Images.

Hmmm... maybe I spoke to soon? And by adding the output to the module the descriptions might popup on more places than desired? I will shut up, and do some testing before posting more suggestions :-)

2 Oct 2006, 12:52 PM
#7
peanut77 avatar

peanut77

Zen Follower

Join Date:
Feb 2005
Posts:
266
Plugin Contributions:
0

Re: Category Descriptions displayed along-side Category Images.

HI Paulm

This is the file I am trying to edit to pull in the descriptions too as well - will be in touch if I manage anything.. :-)

2 Oct 2006, 1:48 PM
#8
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: Category Descriptions displayed along-side Category Images.

Hi peanut77,

I already got it working as I want it (currently) to work, I only did not get to posting it here yet.

On 1.3.5, I changed modules/category_row.php to (saved the editted file to my over rides template dir of course):

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

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

*/
// bof add categories descriptions to category rows paulm                                          
    $categories->fields['categories_description'] = zen_get_category_description($categories->fields['categories_id'], $_SESSION['languages_id']);
                                              
    $list_box_contents[$row][$col]['params'] = 'class="categoryListBoxContents"' . ' ' . 'style="width:' . $col_width . '%;"';
    $list_box_contents[$row][$col]['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) . '</a>';
              
    //$list_box_contents[$row][$col]['text'] .= '<a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . $categories->fields['categories_name'] . '</a>';                                         
    $list_box_contents[$row][$col]['text'] .= '<div class="rowCategoriesDescription">';
    //$list_box_contents[$row][$col]['text'] .= '<h4><a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . $categories->fields['categories_name'] . '</a></h4>';
    $list_box_contents[$row][$col]['text'] .= '<h4>'. $categories->fields['categories_name'] . '</h4>';
    $list_box_contents[$row][$col]['text'] .= '<div>' . $categories->fields['categories_description'] . '</div>';
    $list_box_contents[$row][$col]['text'] .= '<a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . CATEGORY_ROW_GOTO_PRODUCTS_TEXT . '<span>' . $categories->fields['categories_name'] . '</span>' . '</a></h4>';
    $list_box_contents[$row][$col]['text'] .= '</div>';                                       
// eof add categories descriptions to category rows paulm                                          
    $col ++;
    if ($col > (MAX_DISPLAY_CATEGORIES_PER_ROW -1)) {
      $col = 0;
      $row ++;
    }
    $categories->MoveNext();
  }
}
?>

Of course improvements are possible, but this way it's one easy edit (not counting CSS styling edits).

2 Oct 2006, 1:55 PM
#9
peanut77 avatar

peanut77

Zen Follower

Join Date:
Feb 2005
Posts:
266
Plugin Contributions:
0

Re: Category Descriptions displayed along-side Category Images.

Hi Paulm

Can I just say I was well off the beaten track!!! (I'm nearly bald from trying) Would you mind if I copied your hard work and gave it a whirl?

Cheers

2 Oct 2006, 2:13 PM
#10
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: Category Descriptions displayed along-side Category Images.

peanut77:

(I'm nearly bald from trying) :laugh: (I must admit I know the feeling though ;- )

Please feel free to do with it whatever you like! And let me know how it works out :-)

2 Oct 2006, 2:26 PM
#11
peanut77 avatar

peanut77

Zen Follower

Join Date:
Feb 2005
Posts:
266
Plugin Contributions:
0

Re: Category Descriptions displayed along-side Category Images.

PaulM you are some sort of genius!!!

http://spanishlife.bpweb.net/mainland-spain-c-1.html

cooking with gas - thank you for figuring this out :-) you have saved me a week of sleepless nights :-)

2 Oct 2006, 2:35 PM
#12
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: Category Descriptions displayed along-side Category Images.

I am glad it helped :-)

And nice too see how well it fits on you site. You managed to style it quickly and nicely!

4 Oct 2006, 7:00 AM
#13
fishysteve avatar

fishysteve

New Zenner

Join Date:
Aug 2004
Posts:
13
Plugin Contributions:
0

Re: Category Descriptions displayed along-side Category Images.

Hiya Guys,
I've been playing around enjoying V1.3.5. I am building a site for a friend and have been looking all over the forums for an answer to my problem. When more than 1 item is in a category the description is all squashed and the page looks awful I've included an image because it's hard for me to explain and not sure if this thread was talking about the same problem as the sites I've viewed from here appear to be OK now..
It happens in the stock classic theme and I tried another theme (Candied Blueberry) to see if this fixed the problem but as you can see it's the same deal.
Could someone please help, Thanks

4 Oct 2006, 8:07 AM
#14
peanut77 avatar

peanut77

Zen Follower

Join Date:
Feb 2005
Posts:
266
Plugin Contributions:
0

Re: Category Descriptions displayed along-side Category Images.

Hi Steve

Is that the category description? ( a wee bitty hard to tell - sorry ) If so you might want to try displaying the categories in columns. that way the images will sit above the descriptions If that is your product description I would amend the character length to be a lot shorter and also play around with the product listing layout.

4 Oct 2006, 8:10 AM
#15
peanut77 avatar

peanut77

Zen Follower

Join Date:
Feb 2005
Posts:
266
Plugin Contributions:
0

Re: Category Descriptions displayed along-side Category Images.

Apologies having look at your thumbnail again - it looks like a product listing - as you don't have any modle numbers - I would turn that off and then take your character length for the product description down quite a bit in word/ character size

that should help somewhat in stopping your tall product descriptions.

4 Oct 2006, 8:22 AM
#16
fishysteve avatar

fishysteve

New Zenner

Join Date:
Aug 2004
Posts:
13
Plugin Contributions:
0

Re: Category Descriptions displayed along-side Category Images.

Hiya mate,
Yes it's the subcategory with the products listed..
When only 1 item is in the sub-category the text wraps around the image nicely. When there are more than 1 it squashes the text as shown in the pic...
When I look at the page while loading it starts ok but kinda jumps to the squashed result, almost like it wants to display properly but has a glitch of some sort... Not sure if that helps.
I'm confused..

4 Oct 2006, 9:03 AM
#17
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: Category Descriptions displayed along-side Category Images.

This thread is about "Category Descriptions" though. But your problem is with the "Products Descriptions", and is releated to your product listing code/settings.

I think it's better to do a search on that, or start a new thread about it.

14 Nov 2006, 3:00 AM
#18
duckarina avatar

duckarina

New Zenner

Join Date:
Nov 2006
Posts:
14
Plugin Contributions:
0

Re: Category Descriptions displayed along-side Category Images.

Thank you! You have solved one of my problems.

The remaining problem is - how do I list the sub-categories in a single column in the center column?

I am new to Zen and to php - do you have any suggestions of good reference books I could buy?

14 Nov 2006, 1:43 PM
#19
peanut77 avatar

peanut77

Zen Follower

Join Date:
Feb 2005
Posts:
266
Plugin Contributions:
0

Re: Category Descriptions displayed along-side Category Images.

I'm not 100% sure if you can do this - in config - maximum values you can change the number of categories but I can't see sub categories - maybe doing a wee search of sub categories might throw up the answer.

Best way to learn zen is to read the faq's, wiki and the forum - 9 times out 10 it's the unfamiliarity of the screens which cause the most problems (i.e its in front of you but you can't see it)

And I made a lot of mistakes before I got my head round it but thats half the battle - having used lots of ecommerce packages over the years zen is totally the best - and if you can - donate to the team - there worth it!