Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2007
    Location
    South, UK
    Posts
    66
    Plugin Contributions
    0

    Default Product Listing Layout Issue

    Hello, I've added a couple of DIVs into my modules/product_listing.php file in order to display the products price in the top right corner of the products image.

    I've also done the same to the homepage featured / new product sections and this works well. eg:

    http://rareadidas.com/

    However on the product listing section the first product displayed has no price displayed, instead it's price is on the next products image and this continues for the rest of the listing (so the wrong prices are on the wrong products!). eg:

    http://rareadidas.com/adidas-superstar-c-11.html

    I've gone through the coding and I cant understand why this is, but I am self-taught and by no means a knowledgeable coder.

    This is where I added the coding:

    Code:
    } else {
                $lc_text = '<div id="indexthumb"><div id="indexthumbprice">' . $lc_price. '</div><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT, 'class="listingProductImage"') . '</a></div>';
    The new DIVs are indexthumb and indexthumbprice.

    Here's the whole products_listing.php with the bits I added in red -

    Code:
    <?php
    /**
     * product_listing module
     *
     * @package modules
     * @copyright Copyright 2003-2007 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: product_listing.php 6787 2007-08-24 14:06:33Z drbyte $
     * UPDATED TO WORK WITH COLUMNAR PRODUCT LISTING For Zen Cart v1.3.6 - 10/25/2006
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die('Illegal Access');
    }
    // Column Layout Support originally added for Zen Cart v 1.1.4 by Eric Stamper - 02/14/2004
    // Upgraded to be compatible with Zen-cart v 1.2.0d by Rajeev Tandon - Aug 3, 2004
    // Column Layout Support (Grid Layout) upgraded for v1.3.0 compatibility DrByte 04/04/2006
    //
    if (!defined('PRODUCT_LISTING_LAYOUT_STYLE')) define('PRODUCT_LISTING_LAYOUT_STYLE','rows');
    if (!defined('PRODUCT_LISTING_COLUMNS_PER_ROW')) define('PRODUCT_LISTING_COLUMNS_PER_ROW',3);
    $row = 0;
    $col = 0;
    $list_box_contents = array();
    $title = '';
    
    $max_results = (PRODUCT_LISTING_LAYOUT_STYLE=='columns' && PRODUCT_LISTING_COLUMNS_PER_ROW>0) ? (PRODUCT_LISTING_COLUMNS_PER_ROW * (int)(MAX_DISPLAY_PRODUCTS_LISTING/PRODUCT_LISTING_COLUMNS_PER_ROW)) : MAX_DISPLAY_PRODUCTS_LISTING;
    
    
    $show_submit = zen_run_normal();
    $listing_split = new splitPageResults($listing_sql, $max_results, 'p.products_id', 'page');
    $zco_notifier->notify('NOTIFY_MODULE_PRODUCT_LISTING_RESULTCOUNT', $listing_split->number_of_rows);
    $how_many = 0;
    
    // Begin Row Layout Header
    if (PRODUCT_LISTING_LAYOUT_STYLE == 'rows') {		// For Column Layout (Grid Layout) add on module
    
    $list_box_contents[0] = array('params' => 'class="productListing-rowheading"');
    
    $zc_col_count_description = 0;
    $lc_align = '';
    for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
      switch ($column_list[$col]) {
        case 'PRODUCT_LIST_MODEL':
        $lc_text = TABLE_HEADING_MODEL;
        $lc_align = '';
        $zc_col_count_description++;
        break;
        case 'PRODUCT_LIST_NAME':
        $lc_text = TABLE_HEADING_PRODUCTS;
        $lc_align = '';
        $zc_col_count_description++;
        break;
        case 'PRODUCT_LIST_MANUFACTURER':
        $lc_text = TABLE_HEADING_MANUFACTURER;
        $lc_align = '';
        $zc_col_count_description++;
        break;
        case 'PRODUCT_LIST_PRICE':
        $lc_text = TABLE_HEADING_PRICE;
        $lc_align = 'right' . (PRODUCTS_LIST_PRICE_WIDTH > 0 ? '" width="' . PRODUCTS_LIST_PRICE_WIDTH : '');
        $zc_col_count_description++;
        break;
        case 'PRODUCT_LIST_QUANTITY':
        $lc_text = TABLE_HEADING_QUANTITY;
        $lc_align = 'right';
        $zc_col_count_description++;
        break;
        case 'PRODUCT_LIST_WEIGHT':
        $lc_text = TABLE_HEADING_WEIGHT;
        $lc_align = 'right';
        $zc_col_count_description++;
        break;
        case 'PRODUCT_LIST_IMAGE':
        $lc_text = TABLE_HEADING_IMAGE;
        $lc_align = 'center';
        $zc_col_count_description++;
        break;
      }
    
      if ( ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
        $lc_text = zen_create_sort_heading($_GET['sort'], $col+1, $lc_text);
      }
    
    
    
      $list_box_contents[0][$col] = array('align' => $lc_align,
                                          'params' => 'class="productListing-heading"',
                                          'text' => $lc_text );
    }
    
    } // End Row Layout Header used in Column Layout (Grid Layout) add on module
    
    /////////////  HEADER ROW ABOVE /////////////////////////////////////////////////
    
    $num_products_count = $listing_split->number_of_rows;
    
    if ($listing_split->number_of_rows > 0) {
      $rows = 0;
      // Used for Column Layout (Grid Layout) add on module
      $column = 0;	
      if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns') {
        if ($num_products_count < PRODUCT_LISTING_COLUMNS_PER_ROW || PRODUCT_LISTING_COLUMNS_PER_ROW == 0 ) {
          $col_width = floor(100/$num_products_count) - 0.5;
        } else {
          $col_width = floor(100/PRODUCT_LISTING_COLUMNS_PER_ROW) - 0.5;
        }
      }
      // Used for Column Layout (Grid Layout) add on module
    
    
      $listing = $db->Execute($listing_split->sql_query);
      $extra_row = 0;
      while (!$listing->EOF) {
    
        if (PRODUCT_LISTING_LAYOUT_STYLE == 'rows') { // Used in Column Layout (Grid Layout) Add on module
        $rows++;
    
        if ((($rows-$extra_row)/2) == floor(($rows-$extra_row)/2)) {
          $list_box_contents[$rows] = array('params' => 'class="productListing-even"');
        } else {
          $list_box_contents[$rows] = array('params' => 'class="productListing-odd"');
        }
    
        $cur_row = sizeof($list_box_contents) - 1;
        }   // End of Conditional execution - only for row (regular style layout)
    
        $product_contents = array(); // Used For Column Layout (Grid Layout) Add on module
    
        for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
          $lc_align = '';
          switch ($column_list[$col]) {
            case 'PRODUCT_LIST_MODEL':
            $lc_align = '';
            $lc_text = $listing->fields['products_model'];
            break;
            case 'PRODUCT_LIST_NAME':
            $lc_align = '';
            if (isset($_GET['manufacturers_id'])) {
              $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' ;
            } else {
              $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
            }
            break;
            case 'PRODUCT_LIST_PRICE':
            $lc_price = zen_get_products_display_price($listing->fields['products_id']) ;
            $lc_align = '';
            $lc_text =  '';
    
            break;
            case 'PRODUCT_LIST_IMAGE':
            $lc_align = 'center';
            if ($listing->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
              $lc_text = '';
            } else {
              if (isset($_GET['manufacturers_id'])) {
                $lc_text = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT, 'class="listingProductImage"') . '</a>';
              } else {
                $lc_text = '<div id="indexthumb"><div id="indexthumbprice">' . $lc_price. '</div><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT, 'class="listingProductImage"') . '</a></div>';
              }
            }
            break;
          }
    
          $product_contents[] = $lc_text; // Used For Column Layout (Grid Layout) Option
    
          if (PRODUCT_LISTING_LAYOUT_STYLE == 'rows') {
          $list_box_contents[$rows][$col] = array('align' => $lc_align,
                                                  'params' => 'class="productListing-data"',
                                                  'text'  => $lc_text);
        }
        }
    
        // add description and match alternating colors
        //if (PRODUCT_LIST_DESCRIPTION > 0) {
        //  $rows++;
        //  if ($extra_row == 1) {
        //    $list_box_description = "productListing-data-description-even";
        //    $extra_row=0;
        //  } else {
        //    $list_box_description = "productListing-data-description-odd";
        //    $extra_row=1;
        //  }
        //  $list_box_contents[$rows][] = array('params' => 'class="' . $list_box_description . '" colspan="' . $zc_col_count_description . '"',
        //  'text' => zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION));
        //}
    
        // Following code will be executed only if Column Layout (Grid Layout) option is chosen
        if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns') {
          $lc_text = implode($product_contents);
          $list_box_contents[$rows][$column] = array('params' => 'class="centerBoxContentsProducts centeredContent back" ' ,
                                                     'text'  => $lc_text);
          $column ++;
          if ($column >= PRODUCT_LISTING_COLUMNS_PER_ROW) {
            $column = 0;
            $rows ++;
          }
        }
        // End of Code fragment for Column Layout (Grid Layout) option in add on module
        $listing->MoveNext();
      }
      $error_categories = false;
    } else {
      $list_box_contents = array();
    
      $list_box_contents[0] = array('params' => 'class="productListing-odd"');
      $list_box_contents[0][] = array('params' => 'class="productListing-data"',
                                                  'text' => TEXT_NO_PRODUCTS);
    
      $error_categories = true;
    }
    
    if (($how_many > 0 and $show_submit == true and $listing_split->number_of_rows > 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 1 or  PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 3) ) {
      $show_top_submit_button = true;
    } else {
      $show_top_submit_button = false;
    }
    if (($how_many > 0 and $show_submit == true and $listing_split->number_of_rows > 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART >= 2) ) {
      $show_bottom_submit_button = true;
    } else {
      $show_bottom_submit_button = false;
    }
    
    
    
      if ($how_many > 0 && PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == true and $listing_split->number_of_rows > 0) {
      // bof: multiple products
        echo zen_draw_form('multiple_products_cart_quantity', zen_href_link(FILENAME_DEFAULT, zen_get_all_get_params(array('action')) . 'action=multiple_products_add_product'), 'post', 'enctype="multipart/form-data"');
      }
    
    ?>
    I hope I've explained that well enough, I'm sure it's something simple I've overlooked.... any help would be appreciated.... I'm completely stuck!

    Thanks

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

    Default Re: Product Listing Layout Issue

    $lc_price is not reset at each iteration of the loop, but only when the price for the current product is being prepared for display. If that happens after the current product's image is prepared, $lc_price will still be holding the value from the last product. For the first product, $lc_price is empty at that point.

    Substitute
    zen_get_products_display_price($listing->fields['products_id'])
    for
    $lc_price
    in your new code.

  3. #3
    Join Date
    Dec 2007
    Location
    South, UK
    Posts
    66
    Plugin Contributions
    0

    Default Re: Product Listing Layout Issue

    Wow, that was quick!

    Many thanks for that, it's working now. I'm slowly learning more on the coding side!

    Cheers

  4. #4
    Join Date
    Mar 2011
    Posts
    33
    Plugin Contributions
    0

    Default Re: Product Listing Layout Issue

    Hi guys, this work like a charm.
    Couple questions though if you don't mind.

    1.) How do I go about removing the original price listing (the one not in a DIV)?

    2.) What to I alter to place the "BUY NOW" button into a DIV so that I can then align all the buttons on the same horizontal line.
    This question has been posted several times, but I've found no clear answers. It seems you guys would know what to do.

    This is my page
    http://beautyglowshop.com/index.php?...ex&cPath=19_93

    It looks like I mess, I hope you guys can help me out.


    Appreciation in advance.
    This community rocks!
    Last edited by makehveli; 19 Aug 2011 at 06:30 AM. Reason: bad grammar

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

    Default Re: Product Listing Layout Issue

    You might want to search the forum for "Flexible Product Listing", which does all the separating and identifying of elements. It is attached to post 50 of the original thread on the subject.

  6. #6
    Join Date
    Mar 2011
    Posts
    33
    Plugin Contributions
    0

    Default Re: Product Listing Layout Issue

    thank you gjh42
    works brilliantly!

 

 

Similar Threads

  1. prodcut listing layout issue
    By sergiol in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 7 Oct 2010, 07:22 PM
  2. Change Category Product Listing Layout To Match All Product Listing
    By Alfonzo in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 21 Sep 2010, 11:49 AM
  3. Product Listing Page Layout Issue
    By sakkhan in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 20 Sep 2010, 01:34 PM
  4. Column Layout Grid for Product Listing Issue
    By jameshumes in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 1 Jul 2009, 05:58 PM
  5. Next, Previous, Listing Button Layout Issue
    By sfuredi in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 28 May 2009, 03:15 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