Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Sep 2010
    Location
    crewe
    Posts
    41
    Plugin Contributions
    0

    Default Categories in boxes

    Hi
    I would like to have "categories" displayed on the main page (the center column) as well as a short description of each on of them. I already have categories on the main page in two nice columns, but I have no idea how to add this descriptions and make them look like they were in separate boxes. Is it possible using some Zen Cart's options I don't know, or I should install a separate module? I will be very greatful for indicating the right solution :)

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

    Default Re: Categories in boxes

    Do you want to use the regular category description that you can enter in admin, or a different version of description? It shouldn't be too hard to add to the SQL query to get the regular descriptions of all of the subcategories in the current list, and then output them along with the name and image.

    The separate boxes is just a matter of styling in the stylesheet.

  3. #3
    Join Date
    Sep 2010
    Location
    crewe
    Posts
    41
    Plugin Contributions
    0

    Default Re: Categories in boxes

    Thank you for a fast reply.
    It sounds interesting :) I added the description when I was creating a new category, so that should be ok as a starting point ;)
    Can I get some hints how to add the SQL query you mentioned?

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

    Default Re: Categories in boxes

    Note that I am not a SQL expert, but I think it would work like this.

    In /includes/modules/pages/index/main_template_vars.php, find this
    PHP Code:
    if ($category_depth == 'nested')
    {
      
    $sql "SELECT cd.categories_name, c.categories_image
              FROM   " 
    TABLE_CATEGORIES " c, " TABLE_CATEGORIES_DESCRIPTION " cd
              WHERE      c.categories_id = :categoriesID
              AND        cd.categories_id = :categoriesID
              AND        cd.language_id = :languagesID
              AND        c.categories_status= '1'"
    ;

      
    $sql $db->bindVars($sql':categoriesID'$current_category_id'integer');
      
    $sql $db->bindVars($sql':languagesID'$_SESSION['languages_id'], 'integer');
      
    $category $db->Execute($sql); 
    and add something like
    "SELECT cd.categories_name, c.categories_image, cd.categories_description
    to get
    PHP Code:
    if ($category_depth == 'nested')
    {
      
    $sql "SELECT cd.categories_name, c.categories_image, cd.categories_description
              FROM   " 
    TABLE_CATEGORIES " c, " TABLE_CATEGORIES_DESCRIPTION " cd
              WHERE      c.categories_id = :categoriesID
              AND        cd.categories_id = :categoriesID
              AND        cd.language_id = :languagesID
              AND        c.categories_status= '1'"
    ;

      
    $sql $db->bindVars($sql':categoriesID'$current_category_id'integer');
      
    $sql $db->bindVars($sql':languagesID'$_SESSION['languages_id'], 'integer');
      
    $category $db->Execute($sql); 
    Then in /includes/modules/your_template/category_row.php, find
    PHP Code:
        $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_WIDTHSUBCATEGORY_IMAGE_HEIGHT) . '<br />' $categories->fields['categories_name'] . '</a>'); 
    and add
    . '<br />' . $categories->fields['categories_description']
    to get
    PHP Code:
        $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_WIDTHSUBCATEGORY_IMAGE_HEIGHT) . '<br />' $categories->fields['categories_name'] . '<br />' $categories->fields['categories_description'] . '</a>'); 

  5. #5
    Join Date
    Sep 2010
    Location
    crewe
    Posts
    41
    Plugin Contributions
    0

    Default Re: Categories in boxes

    Thank you very much :)
    I did everything as you written, but it doesn't seem to be working.
    I'll try ine more time to make sure though.
    Do you thik that adding a table to the main page using html would be a good alternative for that?

    P.S.
    One more thing, because I don't know if I got it right. If there is no category_row.php file in the directory you indicated, should I copy it from the "modules" folder?
    Sorry for asking this kind of questions, but it is the first time I'm using Zen Cart :)
    Last edited by stood; 20 Sep 2010 at 09:53 PM.

  6. #6
    Join Date
    Sep 2010
    Location
    crewe
    Posts
    41
    Plugin Contributions
    0

    Default Re: Categories in boxes

    I used a table, so don't worry about me any more :)
    I nested tables inside one big table, so that I could position images and links as I want. It's pretty time consuming and probably rather primitive, but it works for me
    Thank you for your time once again :)
    Cheers

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

    Default Re: Categories in boxes

    Yes, nested tables are antiquated and clumsy technology, and do not comform to current Web standards. But if they did the job, that's good enough for now.

    Copying category_row.php from /modules/ into /modules/your_template/ to customize it is the correct method.

    When you said "it doesn't appear to be working", exactly what was happening? Was there an error message or blank screen, or did it just not show up? I was just guessing that the categories_description table has a field named categories_description; that would probably be the first thing to verify.

  8. #8
    Join Date
    Sep 2010
    Location
    crewe
    Posts
    41
    Plugin Contributions
    0

    Default Re: Categories in boxes

    Nothing showed up :)
    Do you think that it would be better to use divs instead of tables? I tryed, but then nothing appeared on the main page. But it is possible, that it was my mistake

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

    Default Re: Categories in boxes

    Divs with class or id tags would give you a simple, clean structure, which you could then style in your stylesheet.

    I checked in the wiki, and the database table field is correct. It seems that the right information in the right language should be fetched, but apparently somewhere along the line it is being lost.

  10. #10
    Join Date
    Sep 2010
    Location
    crewe
    Posts
    41
    Plugin Contributions
    0

    Default Re: Categories in boxes

    Ok, so I will do it using divs but this time will be more careful :)
    Thank you once again :)

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Display Categories In Separate Boxes
    By torvista in forum Addon Sideboxes
    Replies: 62
    Last Post: 26 Sep 2015, 02:33 PM
  2. v139h categories boxes in the middle of main page
    By dustbowl in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 10 Mar 2012, 03:53 AM
  3. Categories and banner side boxes
    By joe2011uk in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 20 Mar 2011, 08:21 PM
  4. Many Categories boxes
    By Triforcetechs in forum Basic Configuration
    Replies: 1
    Last Post: 8 Apr 2007, 02:32 AM
  5. Remove Categories and Information Boxes
    By point4design in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 27 Oct 2006, 09:19 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