Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    May 2008
    Posts
    11
    Plugin Contributions
    0

    Default Main Category - sub heading sort - is it possible?

    Hi,

    I'm wondering if it's possible to sort or analyse sub-categories within the center section window?

    I'm setting up a printer cartridge Zen Cart e-commerce site and want to group the HP printers into sub groups in the main center window.

    I know I can hard code the category sort by entering a sort order number in the category setup screen - but I would like to have a sub-heading just above each group of these printers.

    Eg. All the HP types of printers are under the HP category.
    If I assign, say 10 to all the Deskjet Printer Categories and 20 to all the officejet Printer Categories - would it be possible for the center screen to display the categories
    like this:-

    HP Deskjet Printers:
    Deskjet 1 - Deskjet 2 - Deskjet 3
    Deskjet 4 ..... so on and so on

    HP Officejet Printers:
    Officejet 1 - Officejet 2 - Officejet 3
    Officejet 4 .... so on and so on

    Any help would be appreciated.

    Many thanks,
    John

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

    Default Re: Main Category - sub heading sort - is it possible?

    As you are using the Column Grid mod for the display, you would add/modify the code in that copy of /includes/modules/your_template/product_listing.php.

    Find this section
    PHP Code:
        // Following code will be executed only if Column Layout (Grid Layout) option is chosen
        
    if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns') {
          
    $lc_text implode('<br />'$product_contents);
          
    $list_box_contents[$rows][$column] = array('params' => 'class="centerBoxContentsProducts centeredContent back"' ' ' 'style="width:' $col_width '%;"',
                                                     
    'text'  => $lc_text);
          
    $column ++;
          if (
    $column >= PRODUCT_LISTING_COLUMNS_PER_ROW) {
            
    $column 0;
            
    $rows ++;
          }
        } 
    and replace the
    $lc_text = implode('<br />', $product_contents);
    line with
    PHP Code:
          $section_check $listing->fields['products_name'];
          
    $section_header '';
          if (
    in_array($section_check,explode(",",'list_names_to_start_new_lines_here,separated_by_commas,and_no_spaces'))) {
            
    $column = -1;
            
    $rows ++;
            switch (
    $section_check) {
            case 
    "first name":
              
    $section_header 'First Section';
            break;
            case 
    "second name":
              
    $section_header 'Second Section';
            break;
            } 
    //switch
          
    //if
          
    $lc_text '<div class="sectionHeader">' $section_header '</div>' implode('<br />'$product_contents); 
    Put all of the names that begin sections in the explode function. I'm not sure about the effect of internal spaces in the names, whether they will cause problems or not. If so, some more code tweaking will be needed.

    Repeat the case ... break; code for each section heading in the list.

    Style .sectionHeader {} as desired in your stylesheet.

    I haven't tested this, and it probably will need some adjusting, but I think this approach will do the job.

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

    Default Re: Main Category - sub heading sort - is it possible?

    First correction: the end of the code replacement needs to only add the div when there is a section header.
    PHP Code:
            //switch
          
    //if
          
    $lc_text '<div class="sectionHeader">' $section_header '</div>' implode('<br />'$product_contents); 
    should be
    PHP Code:
            //switch
            
    $section_header '<div class="sectionHeader">' $section_header '</div>';
          } 
    //if
          
    $lc_text $section_header implode('<br />'$product_contents); 

  4. #4
    Join Date
    May 2008
    Posts
    11
    Plugin Contributions
    0

    Default Re: Main Category - sub heading sort - is it possible?

    Hi Glenn,

    Thanks for your reply and for looking into this for me.

    I should have posted example links to the site - sorry.

    I think the product listing looks better in rows (some printers have up to 9 different cartridges that work in them) - so I don't think the column grid mod for products is being used - it might be though as I'm only new to ZC.
    Eg Product page
    http://www.123-inkjet-cartridges.co....&cPath=919_981

    I'm hoping to organise the Categories that are in the main HP holding category here
    http://www.123-inkjet-cartridges.co....ndex&cPath=919

    I've only loaded a small selection up to now and the page is already getting quite long - as I'm not showing any images in this section, is it possible to reduce the space between each row?

    Thanks again for your help

    John

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

    Default Re: Main Category - sub heading sort - is it possible?

    Ah yes, the link and description makes a difference. You have multiple products for each printer model, so the header insertion code would not go in any version of product_listing.php. It may be category_row.php that needs to be edited. The same principles will apply, though many of the variables will be different. I'll look at that later - have to go now.

  6. #6
    Join Date
    May 2008
    Posts
    11
    Plugin Contributions
    0

    Default Re: Main Category - sub heading sort - is it possible?

    The site has been down for a few days and I've changed the url structure.

    So I thought I would post links to the main HP category page again:-
    http://www.123-inkjet-cartridges.co....cartridges-23/

    It would be fantastic if the different families of HP printers could be separated (to make the page more readable) with titles like:-

    HP Deskjet Series Printer Cartridges:-
    deskjet 1 deskjet 2 deskjet 3 ....

    HP Officejet Series Printer Ink Cartridges:-
    Officejet 1 Officejet 2 Officejet 3....

    Hope you can help.

    Many thanks,
    John

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

    Default Re: Main Category - sub heading sort - is it possible?

    Copy /includes/modules/category_row.php to /includes/modules/your_template/category_row.php.
    Find this line
    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 replace with
    PHP Code:
          // subheadings - gjh42 20080617
          
    $section_check $categories->fields['categories_name'];
          
    $section_header '';
          if (
    in_array($section_check,explode(",",'list_names_to_start_new_lines_here,separated_by_commas,and_no_spaces'))) {
            
    $col 0;
            
    $row ++;
            switch (
    $section_check) {
            case 
    "first name":
              
    $section_header 'First Section';
            break;
            case 
    "second name":
              
    $section_header 'Second Section';
            break;
            } 
    //switch
          
    $list_box_contents[$row][$col] = array('params' => 'class="sectionHeader" style="width: 100%;"',
                                               
    'text' => $section_header);
          
    $row ++;
          } 
    //if                       
          // /subheadings
        
    $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>'); 
    This file works a bit differently than product_listing.php, but I think this version of the code will do the job. Let me know if anything needs to be fixed.

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

    Default Re: Main Category - sub heading sort - is it possible?

    Here is a tweak to improve display consistency.
    The code above will start a new line for the heading, but if the last row was filled, there will already be a new line. If there is a new line, $col will be 0, so replace this
    PHP Code:
            $col 0;
            
    $row ++; 
    with this
    PHP Code:
            $col != 0?$row ++:''
            
    $col 0

  9. #9
    Join Date
    May 2008
    Posts
    11
    Plugin Contributions
    0

    Default Re: Main Category - sub heading sort - is it possible?

    Glenn - Thanks so much for looking at this for me.

    My lack of knowledge of ZC and my application of your coding is letting me down...

    In the section of code below:-
    if in_array($section_check,explode(",",'list_names_to_start_new_lines_here,separate d_by_commas,and_no_spaces'))) {
    Do I replace the 'list_names_to_start_new....' with example 'HP Deskjet,HP Officejet,....'
    Or, do I insert these between the "" double quotes?

    Also, is this the only place I need to adjust your code?

    I'm really sorry - I have tried a few combinations - without any change or the center section just goes blank.

    Thanks in advance of your help.

    Regards,
    John

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

    Default Re: Main Category - sub heading sort - is it possible?

    That is the right format you posted for the explode list.

    You also need to put each one of those items in a case statement - replace
    case "first name":
    with
    case "HP Deskjet":
    and
    $section_header = 'First Section';
    with
    $section_header = 'HP Deskjet Printers'; //or whatever you want for the header

    Repeat for each item in the list.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 Display images of Sub-Sub category in Main page while navigating.
    By Javier Romero in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 3 May 2013, 10:02 AM
  2. Replies: 1
    Last Post: 1 May 2013, 10:20 PM
  3. sub category heading displays differently
    By usr50 in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 15 Apr 2011, 09:34 PM
  4. Display category heading & sub-category
    By g_force in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 30 Jun 2009, 05:40 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