Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Changing layout for product listing


Recommended Posts

I'm setting up a small site using osCommerce and I'm having a lot of trouble figuring out how to get my product listing page looking right. My ultimate goal is to get this page :




To look similar to this page :




Here's are the two biggest problems I've been having :


1) How do I get item name, description, price, etc. into the same column? I've played around with product_listing.php a bit but I can't figure out how all that data gets throw into a table.


2) How do I stagger the product output so that the odd products have an image on the left and description on the right, while the even products are reversed?

Link to comment
Share on other sites

The answer to both of your questions does indeed lie in product_listing.php. Look for this code around line 79:

      if (($rows/2) == floor($rows/2)) {
       $list_box_contents[] = array('params' => 'class="productListing-even"');
     } else {
       $list_box_contents[] = array('params' => 'class="productListing-odd"');

     $cur_row = sizeof($list_box_contents) - 1;

     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['products_model'] . ' ';
         case 'PRODUCT_LIST_NAME':
           $lc_align = '';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $lc_text = '<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 {
             $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';

The first five lines determine whether the row is an odd or even number. You'll probably need to move the entire switch string up into that If and make two different versions. The difference in the two versions will be what data goes into what column.


That case 'PRODUCT_LIST_NAME': section produces the product name column data. Note that the first part of the If adds in the manufacturer's name, but the second half is product name alone. You can easily add price into both parts by copying it from the Price column below here and adding it to the $lc_text field. Product description will take a bit more work since that's not a standard column. You'll need to modify the SQL in index.php that retrieves this data, then add that to the same case. Turn off the Price column in the admin panel so it doesn't show up.


You'll need to use the columns for other than their intended purpose in the odd/even sections. I would leave everything the way it is for even, then swap the data in the columns for the odd version. Or the other way around.


All of this code builds an array containing the data that goes into the table. The table itself is built by the productListingBox function that is called near the bottom of the page. You shouldn't need to worry about that; just get the data that you want into that $lc_text field and let the rest take care of itself.


Does that help, or have i just added to the confusion?




See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...