Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / categories split into 2 columns on main page

categories split into 2 columns on main page

Views: 1,662

Results 1 to 7 of 7
3 Oct 2011, 7:11 PM
#1
sidewing avatar

sidewing

New Zenner

Join Date:
Mar 2010
Posts:
17
Plugin Contributions:
0

categories split into 2 columns on main page

hi, i have my categories with images listing on the main page.. but there is 3 in 1 row and 1 in the 2nd row.. i would like it to list as 2x2.. so 2 images in 1 row, then 2 images in the next row.. i only have 4 categories.

ive tried resizing the image display and they just overlap.

that is one issue.. the 2nd issue i am having is i dont want the name of the category displayed below the image, but rather the category description.. how can i do this instead?

keep in mind, both of these are on the main page.

3 Oct 2011, 7:29 PM
#2
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: categories split into 2 columns on main page

The first problem can be browser-specific, so a link to the site would help.

3 Oct 2011, 7:54 PM
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: categories split into 2 columns on main page

What is your setting for admin > Configuration > Maximum Values > Categories To List Per Row ?

Displaying the category's description instead of its name under the image in the listing would require some PHP code changes, to fetch the desired info from the database and then display it. Not a big deal if you are proficient in PHP...

3 Oct 2011, 9:37 PM
#4
sidewing avatar

sidewing

New Zenner

Join Date:
Mar 2010
Posts:
17
Plugin Contributions:
0

Re: categories split into 2 columns on main page

here is the location
http://thegeneralpopulus.com/pop/st0/

the categories to list per row was 3.. changing it to 2 fixed it.. i was unaware that setting was located there, thank you.

now i just need to know how to get it to list the description of the category below the image as a replacement for the name of the category?

i do consider myself proficient in php.. im just not sure where its located, can u point me in the right direction please

3 Oct 2011, 10:13 PM
#5
sidewing avatar

sidewing

New Zenner

Join Date:
Mar 2010
Posts:
17
Plugin Contributions:
0

Re: categories split into 2 columns on main page

k ive made some progress

im editing includes/modules/category_row.php

this part right here:

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

at the very end, that is what i need to change, so i looked in the mysql database and the part that stores the description is categories_description, so i tried changing that last line to this:

'<br />' . $categories->fields['categories_description'] . '</a>');

but it doesnt show anything, if i use categories_id.. it shows the id.. same with the categories_name obviously.. but description doesnt seem to work.. im thinking i have to pull it from the database manually and put it into a variable, but im having trouble figuring out how to do this.. can u guys offer any help?

3 Oct 2011, 10:48 PM
#6
sidewing avatar

sidewing

New Zenner

Join Date:
Mar 2010
Posts:
17
Plugin Contributions:
0

Re: categories split into 2 columns on main page

ok i got it working.. here is the code for the file i was modifying incase someone has the same problem in the future..(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); // $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'] .= '<div>' . $categories->fields['categories_description'] . '</div>'; $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(); } } ?>
3 Oct 2011, 11:48 PM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: categories split into 2 columns on main page

Thanks for posting your solution! I expect it will be useful to people not as proficient in PHP.

Another, possibly more efficient, way of getting the description would be to add it to the list fetched in the db call that builds $categories originally - not sure at the moment what file that would be in, I would have to research it.