Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

product_listing.php editing/layout help


jhande

Recommended Posts

I have been messing around with the code in product_listing.php but just can't get it right, so I must ask for help. :(

 

I am trying to display the product manufacturers_name above the products_name and the products_model below, all in the same space/cell. See image below:

 

klk4.gif

 

Sorry, can't seem to embed the image...

 

Here is the bit of code I have been editing:

case 'PRODUCT_LIST_NAME':
	 if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
		 $prod_list_contents .= '	 <td align="left" width="*"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
	 } else {
		 $prod_list_contents .= '	 <td align="left" width="*"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
	 }
	 break;

 

No matter what I do it either doesn't make a difference or it returns errors.

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

@@jhande

 

You can hack your product_listing.php file a bit. Make sure you have the admin product_listing settings turned on for the fields you want.

 

Change your first switch ($column_list[$col]) { to:

 

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;
}

 

Change the second switch to:

 

 switch ($column_list[$col]) {
 /**
	 case 'PRODUCT_LIST_MODEL':
	 $prod_list_contents .= '	 <td>' . $listing['products_model'] . '</td>';
	 break;
 */
	 case 'PRODUCT_LIST_NAME':
	 if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
		 $prod_list_contents .= '<td>' . ( ( tep_not_null($listing['manufacturers_name']) ) ? $listing['manufacturers_name'] . '<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>' . ( ( tep_not_null($listing['products_model']) ) ? $listing['products_model'] : '' ) . '</td>';
	 } else {
		 $prod_list_contents .= '<td>' . ( ( tep_not_null($listing['manufacturers_name']) ) ? $listing['manufacturers_name'] . '<br />' : '' ) . '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>' . ( ( tep_not_null($listing['products_model']) ) ? '<br />' . $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;
 }

 

Might get you closer but it may not be the best solution out there :)

Matt

Link to comment
Share on other sites

hi jim :)

 

there was a topic where somebody wanted to have the price just under the name or something like that and de dokta postet following piece of code.

 

http://www.oscommerce.com/forums/topic/394967-product-listing-page-name-price/#entry1684151

 

i'm currently trying to changed that so it fits your need......

posting soon......

Link to comment
Share on other sites

@@jhande

 

If you want to center up the Product Name+ heading you can restore the first switch to its original state and then below find:

 

$prod_list_contents .= '	    <td' . (tep_not_null($lc_align) ? ' align="' . $lc_align . '"' : '') . '>' . $lc_text . '</td>';

 

Change that to:

 

if ( ($column_list[$col] != 'PRODUCT_LIST_MANUFACTURER') && ($column_list[$col] != 'PRODUCT_LIST_MODEL') ) {
    $prod_list_contents .= '	    <td' . (tep_not_null($lc_align) ? ' align="' . $lc_align . '"' : '') . '>' . $lc_text . '</td>';
}

 

Should get you close

Matt

Link to comment
Share on other sites

$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_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_NAME':
           if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
             $prod_list_contents .= '        <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
           } else {
             $prod_list_contents .= '        <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
           }
           break;*/

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

$model = '';
$model = $listing['products_model'];

           $prod_list_contents .= '<td><a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a><br />' . $name . '<br />'. $model . '</td>';
           break;

/*case 'PRODUCT_LIST_MODEL':
           $prod_list_contents .= '        <td>' . $listing['products_model'] . '</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 {
?>

 

it does the job but you need to adjust the header (sorting function) and the product name breaks but i guess if you redesign the <td> and give it a bit more width it should fix that problem.

Link to comment
Share on other sites

@@Tsimi

 

Thanks Lambros

hi jim :)

 

there was a topic where somebody wanted to have the price just under the name or something like that and de dokta postet following piece of code.

 

http://www.oscommerce.com/forums/topic/394967-product-listing-page-name-price/#entry1684151

 

i'm currently trying to changed that so it fits your need......

posting soon......

 

Thanks Lambros

 

I seen that post but I just could not adapt it for my needs. I kept making a mess. :blush:

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

@@mattjt83@@Tsimi

 

WOW thanks guys you are just too quick. (w00t)

 

I am trying to make the edits and they just keep rolling in hehe... :D

 

Thanks tons... I need to go outside and have a smoke. Will get on it in a minute. ;)

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

you're very welcome. :thumbsup:

 

i just tried the solution that mattjt83 posted his version looks cleaner and does what you asked for. so either code, mattjt83 or mine work.

 

EDIT: i just realized in my version the manufacturer link works.

 

for the header part you could use something like this, so that you can keep the sorting function if needed. could use some adjustment though

 

switch ($column_list[$col]) {
 case 'PRODUCT_LIST_MODEL':
 $lc_text = TABLE_HEADING_MODEL;
 $lc_align = 'center';
 break;
 case 'PRODUCT_LIST_NAME':
 $lc_text = TABLE_HEADING_PRODUCTS;
 $lc_align = 'right';
 break;
 case 'PRODUCT_LIST_MANUFACTURER':
 $lc_text = TABLE_HEADING_MANUFACTURER;
 $lc_align = 'center';
 break;
 case 'PRODUCT_LIST_PRICE':
 $lc_text = TABLE_HEADING_PRICE;
 $lc_align = 'left';
 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 = 'Sort by:';
 $lc_align = 'right';
 break;
 case 'PRODUCT_LIST_BUY_NOW':
 $lc_text = '';
 $lc_align = 'center';
 break;
}

Link to comment
Share on other sites

Thanks a million guys!!!

 

It's perfect... :thumbsup:

 

A little more playing with line spacing and it's done.

 

Sometimes I just have trouble getting my head around some of this PHP code. :wacko:

 

Thanks again... you guys are GREAT!!!!

 

bk4u.gif

post-116948-0-87471300-1384134141_thumb.gif

post-116948-0-94425500-1384134154_thumb.gif

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

@@mattjt83

 

Good idea Matt... probably best if I post my code. :shifty:

 

I originally edited the code to give the column set widths and then played around very little with the code you supplied.

 

catalog\includes\modules\product_listing.php

 

For setting the column headers:

 

switch ($column_list[$col]) {

 case 'PRODUCT_LIST_MODEL':
 $lc_text = '';
 $lc_align = '';
$lc_width = '';
 break;
 case 'PRODUCT_LIST_NAME':
 $lc_text = TABLE_HEADING_PRODUCTS;
 $lc_align = '';
$lc_width = '*';
 break;
 case 'PRODUCT_LIST_MANUFACTURER':
 $lc_text = '';
 $lc_align = '';
$lc_width = '*';
 break;
 case 'PRODUCT_LIST_PRICE':
 $lc_text = TABLE_HEADING_PRICE;
 $lc_align = 'right';
$lc_width = '50px';
 break;
 case 'PRODUCT_LIST_QUANTITY':
 $lc_text = TABLE_HEADING_QUANTITY;
 $lc_align = 'right';
$lc_width = '*';
 break;
 case 'PRODUCT_LIST_WEIGHT':
 $lc_text = TABLE_HEADING_WEIGHT;
 $lc_align = 'right';
$lc_width = '*';
 break;
 case 'PRODUCT_LIST_IMAGE':
 $lc_text = TABLE_HEADING_IMAGE;
 $lc_align = 'center';
$lc_width = '142px';
 break;
 case 'PRODUCT_LIST_BUY_NOW':
 $lc_text = TABLE_HEADING_BUY_NOW;
 $lc_align = 'center';
$lc_width = '110px';
 break;
}

 

For the actual product listings:

I actually have an add on - Show Sold-Out - so you'll see some edits pertaining to the buy now button. You can ignore that hole section of code.

switch ($column_list[$col]) {
/**
	 case 'PRODUCT_LIST_MODEL':
	 $prod_list_contents .= '<td align="left">' . $listing['products_model'] . '</td>';
	 break;
*/
	 case 'PRODUCT_LIST_NAME':
			 if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
					 $prod_list_contents .= '<td align="left" width="*">' . ( ( tep_not_null($listing['manufacturers_name']) ) ? $listing['manufacturers_name'] . '<br />' : '' ) . '<b><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></b>' . ( ( tep_not_null($listing['products_model']) ) ? '<br />' . $listing['products_model'] : '' ) . '</td>';
			 } else {
					 $prod_list_contents .= '<td align="left" width="*">' . ( ( tep_not_null($listing['manufacturers_name']) ) ? $listing['manufacturers_name'] . '<br />' : '' ) . '<b><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></b>' . ( ( tep_not_null($listing['products_model']) ) ? '<br />' . $listing['products_model'] : '' ) . '</td>';
			 }
			 break;

/**
	 case 'PRODUCT_LIST_MANUFACTURER':
	 $prod_list_contents .= '<td align="left"><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" width="50px"><del>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</del><br /><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" width="50px">' . $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" width="140"><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" width="140"><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':
	 //** ORIGINAL **// $prod_list_contents .= '<td align="center" width="100px">' . 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>';
/** show-soldout-v1.0 for 2.3 **/
if($listing['products_quantity'] == 0 || $listing['products_status']==0)
$prod_list_contents .='<td align="center" width="100px">' . tep_image_button('button_sold_out.gif', IMAGE_BUTTON_SOLD_OUT) . '</td>';
else
$prod_list_contents .= '<td align="center" width="100px">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'products_id')) . 'action=buy_now&products_id=' . $listing['products_id'])) . '</td>';
/** end show-soldout-v1.0 for 2.3 **/
	 break;
 }
 }

 

Hope that helps someone else a little.

 

Thanks again guys... your help was very much appreciated!!! :thumbsup:

post-116948-0-51372800-1384144364_thumb.gif

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...