aftabn10 Posted November 3, 2014 Share Posted November 3, 2014 Hi, I was looking for some help in regards to understanding the order of data within the product_listing.php page. Thanks to the following contribution, I have managed to display the product listing in a grid view but the problem I am having is trying to workout how it is determined that the image shows first and then the product name, price etc. http://addons.oscommerce.com/info/8670 If somebody could help me understand, as I would like to rearrange this and have the product name on top, then the image, price and lastly add to cart button. The following is the code for the product_listing.php that was downloaded from the above contribution. <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2010 osCommerce Released under the GNU General Public License */ ///// BOF CONFIGURATION OPTIONS FOR LIST -OR- GRID LISTING STYLE ///// ///// BOF LIST VIEW OPTIONS ///// //default configuration of stock osCommerce install //if this is set to true $define_grid_view below must be set to false //change to false to use grid view $define_list_view = false; ///// EOF LIST VIEW OPTIONS ///// ///// BOF GRID VIEW OPTIONS ///// //new configuration to use grid product listing style //if this is set to true $define_list_view above must be set to false //change to true to use grid view $define_grid_view = true; //how many items per row in the grid? $items_per_row = '4'; ///// EOF GRID VIEW OPTIONS ///// ///// NO NEED TO EDIT PAST THIS POINT ///// if ( $define_list_view == true ) { $define_grid_view = false; } if ( $define_list_view == false && $define_grid_view == false ) { $define_list_view = true; } $items_per_row = $items_per_row-1; ///// EOF CONFIGURATION OPTIONS FOR LIST -OR- GRID LISTING STYLE ///// $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id'); ?> <div class="contentText"> <?php if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) { ?> <div> <span style="float: right;"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></span> <span><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></span> </div> <br /> <?php } if ( $define_list_view == true && $define_grid_view == false ) {//BOF list view $prod_list_contents = '<div class="ui-widget infoBoxContainer">' . ' <div class="ui-widget-header ui-corner-top infoBoxHeading">' . ' <table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListingHeader">' . ' <tr>'; for ($col=0, $n=sizeof($column_list); $col<$n; $col++) { $lc_align = ''; switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $lc_text = TABLE_HEADING_MODEL; $lc_align = ''; break; case 'PRODUCT_LIST_NAME': $lc_text = TABLE_HEADING_PRODUCTS; $lc_align = ''; break; case 'PRODUCT_LIST_MANUFACTURER': $lc_text = TABLE_HEADING_MANUFACTURER; $lc_align = ''; break; case 'PRODUCT_LIST_PRICE': $lc_text = TABLE_HEADING_PRICE; $lc_align = 'right'; break; case 'PRODUCT_LIST_QUANTITY': $lc_text = TABLE_HEADING_QUANTITY; $lc_align = 'right'; break; case 'PRODUCT_LIST_WEIGHT': $lc_text = TABLE_HEADING_WEIGHT; $lc_align = 'right'; break; case 'PRODUCT_LIST_IMAGE': $lc_text = TABLE_HEADING_IMAGE; $lc_align = 'center'; break; case 'PRODUCT_LIST_BUY_NOW': $lc_text = TABLE_HEADING_BUY_NOW; $lc_align = 'center'; break; } if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) { $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text); } $prod_list_contents .= ' <td' . (tep_not_null($lc_align) ? ' align="' . $lc_align . '"' : '') . '>' . $lc_text . '</td>'; } $prod_list_contents .= ' </tr>' . ' </table>' . ' </div>'; if ($listing_split->number_of_rows > 0) { $rows = 0; $listing_query = tep_db_query($listing_split->sql_query); $prod_list_contents .= ' <div class="ui-widget-content ui-corner-bottom productListTable">' . ' <table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListingData">'; while ($listing = tep_db_fetch_array($listing_query)) { $rows++; $prod_list_contents .= ' <tr>'; for ($col=0, $n=sizeof($column_list); $col<$n; $col++) { switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $prod_list_contents .= ' <td>' . $listing['products_model'] . '</td>'; break; case 'PRODUCT_LIST_MANUFACTURER': $prod_list_contents .= ' <td><a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a></td>'; break; case 'PRODUCT_LIST_PRICE': if (tep_not_null($listing['specials_new_products_price'])) { $prod_list_contents .= ' <td align="right"><del>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</del> <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span></td>'; } else { $prod_list_contents .= ' <td align="right">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td>'; } break; case 'PRODUCT_LIST_QUANTITY': $prod_list_contents .= ' <td align="right">' . $listing['products_quantity'] . '</td>'; break; case 'PRODUCT_LIST_WEIGHT': $prod_list_contents .= ' <td align="right">' . $listing['products_weight'] . '</td>'; break; case 'PRODUCT_LIST_IMAGE': if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) { $prod_list_contents .= ' <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>'; } else { $prod_list_contents .= ' <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>'; } break; case 'PRODUCT_LIST_BUY_NOW': $prod_list_contents .= ' <td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id'])) . '</td>'; break; } } $prod_list_contents .= ' </tr>'; } $prod_list_contents .= ' </table>' . ' </div>' . '</div>'; echo $prod_list_contents; } else { ?> <p><?php echo TEXT_NO_PRODUCTS; ?></p> <?php } }//EOF list view if ( $define_grid_view == true && $define_list_view == false ) {//BOF grid view if ($listing_split->number_of_rows > 0) { $rows = 0; $listing_query = tep_db_query($listing_split->sql_query); $sort_options[0] = array('id' => ' ', 'text' => 'Alphabetically'); $sort_options[1] = array('id' => '3a', 'text' => 'Price Low to High'); $sort_options[2] = array('id' => '3d', 'text' => 'Price High to Low'); $prod_list_contents .= '<div>' . tep_draw_form('filter_by', FILENAME_DEFAULT, 'get') . '<p align="right"><strong>' . TEXT_SORT_PRODUCTS . TEXT_BY . ' </strong>' . tep_draw_hidden_field('cPath', $cPath) . tep_draw_pull_down_menu('sort', $sort_options, '', 'onchange="this.form.submit()"') . tep_hide_session_id() . '</p></form></div>' . "\n"; $prod_list_contents .= ' <div class="ui-widget-content ui-corner-bottom">' . ' <table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListingData">'; while ($listing = tep_db_fetch_array($listing_query)) { $rows++; if ( $rows == '1' ) { $prod_list_contents .= '<tr>'; } $prod_list_contents .= '<td style="text-align:center;">'; for ($col=0, $n=sizeof($column_list); $col<$n; $col++) { switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $prod_list_contents .= '<br />' . $listing['products_model']; break; case 'PRODUCT_LIST_NAME': if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) { $prod_list_contents .= '<br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>'; } else { $prod_list_contents .= '<h3><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></h3>'; } break; case 'PRODUCT_LIST_MANUFACTURER': $prod_list_contents .= '<br /><a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a>'; break; case 'PRODUCT_LIST_PRICE': if (tep_not_null($listing['specials_new_products_price'])) { $prod_list_contents .= '<br /><del>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</del> <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>'; } else { $prod_list_contents .= '<br /><p class="price-text">OUR PRICE:<p class="price">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id']). '</p></p>'); } break; case 'PRODUCT_LIST_QUANTITY': $prod_list_contents .= '<br />' . $listing['products_quantity']; break; case 'PRODUCT_LIST_WEIGHT': $prod_list_contents .= '<br />' . $listing['products_weight']; break; case 'PRODUCT_LIST_IMAGE': if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) { $prod_list_contents .= '<br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; } else { $prod_list_contents .= '<br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; } break; case 'PRODUCT_LIST_BUY_NOW': $prod_list_contents .= '<br />' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id'])); break; } } $prod_list_contents .= '</td>'; if ( $rows > $items_per_row ) { $prod_list_contents .= '</tr>'; $rows = 0; } } $prod_list_contents .= ' </table>' . ' </div>'; echo $prod_list_contents; } else { ?> <p><?php echo TEXT_NO_PRODUCTS; ?></p> <?php } }//EOF grid view if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) { ?> <br /> <div> <span style="float: right;"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></span> <span><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></span> </div> <?php } ?> </div> I would really appreciate it, if someone could give me some pointers as I have been through the grid view code (above) and not sure how the order is worked out as in the code the case for image is shown just before the buy now button. Thanks in advance, hope the above makes sense. Quote Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted November 3, 2014 Share Posted November 3, 2014 it is done from the admin, under the configuration/product_listing section, the order of the different fields is set. Quote KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
aftabn10 Posted November 4, 2014 Author Share Posted November 4, 2014 thanks bruyndoncx, that did the trick. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.