Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2010
    Posts
    17
    Plugin Contributions
    0

    Default 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.

  2. #2
    Join Date
    Feb 2005
    Location
    Lansing, Michigan USA
    Posts
    20,021
    Plugin Contributions
    3

    Default 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. #3
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default 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...

  4. #4
    Join Date
    Mar 2010
    Posts
    17
    Plugin Contributions
    0

    Default 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

  5. #5
    Join Date
    Mar 2010
    Posts
    17
    Plugin Contributions
    0

    Default 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?

  6. #6
    Join Date
    Mar 2010
    Posts
    17
    Plugin Contributions
    0

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

  7. #7
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default 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.

 

 

Similar Threads

  1. v139h Split product attributes into columns
    By sharc316 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 17 Mar 2014, 06:06 PM
  2. v150 How Can I Split Download List Into Multiple Columns?
    By Scully in forum Setting Up Categories, Products, Attributes
    Replies: 4
    Last Post: 26 Nov 2012, 01:17 AM
  3. split categories display on main page
    By skipjensen in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 19 Mar 2011, 05:49 AM
  4. Split Categories to List into 2 columns?
    By sports guy in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 13 Sep 2010, 06:43 AM
  5. Change Number of Columns of Categories on Main Page
    By kabbink in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 25 Mar 2008, 01:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg