Results 1 to 10 of 16

Hybrid View

  1. #1
    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.

  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?

    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

  3. #3
    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

  4. #4
    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.

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

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

    Ok, I have applied as per your instructions - but the printer names are still appearing as before. Details of the code below:

    // subheadings - gjh42 20080617
    $section_check = $categories->fields['categories_name'];
    $section_header = '';
    if (in_array($section_check,explode(",",'HP Deskjet,HP Digital,HP Fax,HP Officejet,HP Photo,HP PSC'))) {
    $col = 0;
    $row ++;
    switch ($section_check) {
    case "HP Deskjet":
    $section_header = 'Hewlett Packard Deskjet Series Printer Cartridges';
    break;
    case "HP Digital":
    $section_header = 'HP Digital Copier Cartridges';
    break;
    case "HP Fax":
    $section_header = 'HP Fax Printer Cartridges';
    break;
    case "HP Officejet":
    $section_header = 'HP Officejet Ink Cartridges';
    break;
    case "HP Photo":
    $section_header = 'HP Photosmart Printer Inks';
    break;
    case "HP PSC":
    $section_header = 'HP Printer/Scanner/Copier Cartridges';
    break;
    case "HP Cartridges":
    $section_header = 'HP Ink Cartridges by References';
    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_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br />' . $categories->fields['categories_name'] . '</a>');

    Can you see where I've gone wrong?

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

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

    For debugging, add an echo statement after this line:
    $section_check = $categories->fields['categories_name'];

    echo 'name is ' . $section_check;

    Does it output anything? The right thing?

    Is the first category name really "HP Deskjet" and not "HP Deskjet 123" or some model number?

    OK, it looks like it is "HP Deskjet 450". You need to use the exact name of the first subcat in the section - it won't match a partial name.
    Last edited by gjh42; 21 Jun 2008 at 12:30 AM.

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

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

    Brilliant - works a treat, I was thinking I just had to state the first two words of the category name - Thanks

    How would I change the font style for 'sectionHeader' - just to make them stand out a bit more?

  8. #8
    Join Date
    Oct 2004
    Posts
    1,045
    Plugin Contributions
    0

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

    I have implemented this mod, but how can I get the subcategories images to show up? Right now, it just shows the section header, and then the subcategories names in each section, but doesn't display the subcategory image.

    Thanks!
    Danielle

  9. #9
    Join Date
    Oct 2004
    Posts
    1,045
    Plugin Contributions
    0

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

    Quote Originally Posted by Danielle View Post
    I have implemented this mod, but how can I get the subcategories images to show up? Right now, it just shows the section header, and then the subcategories names in each section, but doesn't display the subcategory image.

    Thanks!
    Nevermind I tried on another site and it worked great, just something buggy in the first site's template.

    Great little mod!
    Danielle

 

 

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