Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product Listing in Columns v2.0


djmonkey1

Recommended Posts

I have this mod working very well on a couple sites and I was wondering how I could incorporate images into the individual boxes.

 

Similar to this template. You see that all the product boxes have an image at the top (with the product name over it) and a border with the rounded corner images at the bottom. This particular template has the code written in the product_listing.php, but I am not sure how or where to merge similar code into the product_listing_col.php used with this particular contribution.

 

I dont really want to use this template, just want to do something similar with my own images and this contrib.

 

1main.gif

 

 

Thank you for your help in advance!

Link to comment
Share on other sites

  • Replies 456
  • Created
  • Last Reply

Top Posters In This Topic

I have this mod working very well on a couple sites and I was wondering how I could incorporate images into the individual boxes.

 

Similar to this template.

It is not really that complicated. You have to write the table structure in html once till it looks like you want it to look. Then you adjust the order in which the component like image, description, price come into the table in the admin and copy/paste the html in the $lc_text of the component.

 

When the code is run all the html comes together. I think there is a contribution uploaded not so long ago with examples of how to do that with product_listing_col.php. Don't remember the name of it anymore though.

Link to comment
Share on other sites

Can anyone tell me what might be causing this. I found it by accident while I was working on some formatting ideas.

The code below will show it correctly but basically, on the last row of the BUY NOW TABLES

on a product listing page I get a double CLASS reference. It does not double reference on

any other table. Feel free to have a look at the whole page by visiting my website, but this should suffice.

 

Here is a short example

td align="center" class="class="productListing-data" width="25%""> </td>

 

The catch is that will happen regardless of tr class="productListing-even" or tr class="productListing-odd"

 

Last but not least, it doesn't SEEM to be causing an issue , but worry it may as I continue to

format the layout.

 

I did not change the code to this contribution, at least I don't think I did, but it is also attached below for

inspection.

 

 

 

HTML OUTPUT OF MY PAGE - Look at the bottom 4 lines

  .....
......
......

 <tr class="productListing-odd">
<td align="center" class="productListing-data"><a href="http://creativenestings.com/osc22rc1/catalog/index.php?cPath=22&action=buy_now&products_id=36"><img src="includes/sts_templates/full/images/english/buttons/button_buy_now.gif" width="79" height="22" border="0" alt=""></a> </td>
<td align="center" class="productListing-data"><a href="http://creativenestings.com/osc22rc1/catalog/index.php?cPath=22&action=buy_now&products_id=40"><img src="includes/sts_templates/full/images/english/buttons/button_buy_now.gif" width="79" height="22" border="0" alt=""></a> </td>
<td align="center" class="productListing-data"><a href="http://creativenestings.com/osc22rc1/catalog/index.php?cPath=22&action=buy_now&products_id=38"><img src="includes/sts_templates/full/images/english/buttons/button_buy_now.gif" width="79" height="22" border="0" alt=""></a> </td>
<td align="center" class="productListing-data"><a href="http://creativenestings.com/osc22rc1/catalog/index.php?cPath=22&action=buy_now&products_id=29"><img src="includes/sts_templates/full/images/english/buttons/button_buy_now.gif" width="79" height="22" border="0" alt=""></a> </td>
 </tr>
 <tr class="productListing-even">
<td align="center" class="productListing-data" width="25%"> <a href="http://creativenestings.com/osc22rc1/catalog/product_info.php?cPath=22&products_id=31"><img src="product_thumb.php?img=images/15338-9992_TN.jpg&w=100&h=100" width="100" height="100" border="0" alt="Red Peony flower" title="Red Peony flower"></a> <br>
 15338 <br> <a href="http://creativenestings.com/osc22rc1/catalog/product_info.php?cPath=22&products_id=31">Red 
Peony flower</a> <br> $30.00 <br></td>
<td align="center" class="productListing-data" width="25%"> </td>
<td align="center" class="productListing-data" width="25%"> </td>
<td align="center" class="productListing-data" width="25%"> </td>
 </tr>
 <tr class="productListing-even">
<td align="center" class="class="productListing-data" width="25%""><a href="http://creativenestings.com/osc22rc1/catalog/index.php?cPath=22&action=buy_now&products_id=31"><img src="includes/sts_templates/full/images/english/buttons/button_buy_now.gif" width="79" height="22" border="0" alt=""></a> </td>
<td align="center" class="class="productListing-data" width="25%""> </td>
<td align="center" class="class="productListing-data" width="25%""> </td>
<td align="center" class="class="productListing-data" width="25%""> </td>
 </tr>
</table>


....
.....
......

 

 

And here is the PRODUCT_LISTING_COL.PHP

<?php
/*
original: $Id: product_listing.php,v 1.44 2003/06/09 22:49:43 hpdl Exp $

corrected for proper HTML 2005/07/10 JanZ
merged and updated by djmonkey1 with indispensable assistance by JanZ 2005/10/05
v2.1 developed by djmonkey1 with indispensable assistance by the Mighty JanZ  2005/10/09
reverted to  a non-SPPC state by djmonkey1
v 2.2 modified by adilovetini with small feature 2006/04/18
v 2.2.3 small bugfixes, less database queries 2007/12/16 JanZ

osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License

*/

//version 2.2 modification
//if number of column per row is 1, include the original product_listing.php
if (PRODUCT_LIST_NUMCOL == 1) {
include(dirname(__FILE__).'/product_listing.php');

} else {
//display the version 2.2.1 product_listing_col.php code

//bof product listing with attributes
$list_box_contents = array();
$list_box_contents[] = array('params' => 'class="productListing-heading"');
$cur_row = sizeof($list_box_contents) - 1;

// three variables that determine a certain output
$use_tr_for_buy_now_button = false;
$add_multiple = false;
$use_of_attributes = false;

for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
switch ($column_list[$col]) {
	case 'PRODUCT_LIST_MULTIPLE':
		$add_multiple = true;
  $use_of_attributes = true;
		echo '<form name="buy_now_" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'sort')) . 'action=add_multiple', 'NONSSL') . '">';
		break;
	case 'PRODUCT_LIST_BUY_NOW_MULTIPLE':
  $use_of_attributes = true;
		break;
case 'PRODUCT_LIST_BUY_NOW':
  $use_tr_for_buy_now_button = true;
  break;
}
}
//eof product listing with attributes
?>
<?php
$listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');

if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>  <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
 <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
</tr>
</table>
<?php
}

$list_box_contents = array();
global $cart;

if ($listing_split->number_of_rows > 0) {

//BOF version 2.2 modification
if (PRODUCT_LIST_NUMCOL <= 0) {
	$colnum = 3;
	$tdsize = floor(100/3);
} else {
	$colnum = PRODUCT_LIST_NUMCOL;
	$tdsize = floor(100/PRODUCT_LIST_NUMCOL);
}
//EOF version 2.2 modification

$row = 0;
$column = 0;
$listing_query = tep_db_query($listing_split->sql_query);
// BOF v 2.2.1
  $no_of_listings = tep_db_num_rows($listing_query);

 while ($_listing = tep_db_fetch_array($listing_query)) {
$_listing['total'] = ''; // for number of attributes
$listing[] = $_listing;
$list_of_prdct_ids[] = $_listing['products_id'];
 }

// lets save all the separate count queries that check if a product has attributes
// and do it in one (if needed)
 if ($use_of_attributes == true) {
$products_attributes_count_query = tep_db_query("select count(*) as total, patrib.products_id from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id in (" . implode(',', $list_of_prdct_ids) . ") and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "' group by products_id");
	while ($_products_attributes_count = tep_db_fetch_array($products_attributes_count_query)) {
  $products_attributes_count[] = array('products_id' => $_products_attributes_count['products_id'], 'total' => $_products_attributes_count['total']);
}
$no_of_products_with_attributes = count($products_attributes_count);
for ($x = 0; $x < $no_of_listings; $x++) {
  if (!empty($products_attributes_count)) {
	for ($i = 0; $i < $no_of_products_with_attributes; $i++) {
	  if ($listing[$x]['products_id'] == $products_attributes_count[$i]['products_id'] ) {
		$listing[$x]['total'] = $products_attributes_count[$i]['total'];
	  }
	}
  }
} // end for ($x = 0; $x < $no_of_listings; $x++)
 } // end ($use_of_attributes == true)

// an extra query is used for all the specials because joining the table specials in a query
// often results in a slow query if you haven't added additional indexes to that table
// see http://www.oscommerce.com/forums/index.php?s=&showtopic=119077&view=findpost&p=1118789 and further

 $specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where products_id in (" . implode(',', $list_of_prdct_ids) . ") and status = '1'");
 while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'products_price' => '', 'specials_new_products_price' => $specials_array['specials_new_products_price']);
 }

// add the correct specials_new_products_price and replace final_price
 for ($x = 0; $x < $no_of_listings; $x++) {
if (!empty($new_s_prices)) {
  for ($i = 0; $i < count($new_s_prices); $i++) {
	if ($listing[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
	  $listing[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
	}
  }
} // end if (!empty($new_s_prices)
 } // end for ($x = 0; $x < $no_of_listings; $x++)

 $counter = 0;
 $class_for_buy_now = 'class="productListing-data" width="' . $tdsize . '%"';
 for ($x = 0; $x < $no_of_listings; $x++) {

  if ($x % PRODUCT_LIST_NUMCOL == 0) { // start of new row
 if (($counter+1)/2 == floor(($counter+1)/2)) { // start with the background color productListing-odd
// if ($counter/2 == floor($counter/2)) { // if you want to start with the background color productListing-even use this
   $list_box_contents[$row] = array('params' => 'class="productListing-even"');
   $class_for_buy_now_row = 'class="productListing-even"';
 } else {
   $list_box_contents[$row] = array('params' => 'class="productListing-odd"');
   $class_for_buy_now_row = 'class="productListing-odd"';
 }
  } // end if ($x % PRODUCT_LIST_NUMCOL == 0)

	$product_contents = array();
	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[$x]['products_model'] . ' ';
			break;
			case 'PRODUCT_LIST_NAME':
			$lc_align = '';
			if (isset($_GET['manufacturers_id'])) {
				$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . (int)$_GET['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';
			} else {
				$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a> ';
			}
			break;
			case 'PRODUCT_LIST_MANUFACTURER':
			$lc_align = '';
			$lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a> ';
			break;
			case 'PRODUCT_LIST_PRICE':
			$lc_align = 'right';
			if (tep_not_null($listing[$x]['specials_new_products_price'])) {
				$lc_text = ' <s>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span> ';
			} else {
				$lc_text = ' ' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . ' ';
			}
			break;
			case 'PRODUCT_LIST_QUANTITY':
			$lc_align = 'right';
			$lc_text = ' ' . $listing[$x]['products_quantity'] . ' ';
			break;
			case 'PRODUCT_LIST_WEIGHT':
			$lc_align = 'right';
			$lc_text = ' ' . $listing[$x]['products_weight'] . ' ';
			break;
			case 'PRODUCT_LIST_IMAGE':
			$lc_align = 'center';
			if (isset($_GET['manufacturers_id'])) {
				$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . (int)$_GET['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
			} else {
				$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
			}
			break;
			//bof product listing with attributes
			case 'PRODUCT_LIST_BUY_NOW':
	// this button will be in a separate table row for better aligning
	  $buy_now_button_array[] = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action','sort')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW, 'style="padding-top: 5px;"') . '</a> ';
	  $lc_text = ''; // otherwise the previous $lc_text will be outputted again 
			break;
			// Begin Buy Now button with attributes and quantity mod 
			// Begin Add Multiple  with attributes Contrib
			case 'PRODUCT_LIST_MULTIPLE': 
			$lc_align = 'right'; 
			$lc_valign = 'top'; 
			$lc_text = (TABLE_HEADING_MULTIPLE . tep_draw_input_field('Qty_ProdId_' . $listing[$x]['products_id'], '0', 'size="4"'));
	if ((int)$listing[$x]['total'] > 0) {
				$lc_text .= '<table border="0" cellpadding="0" cellspacing"0">';
				$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing[$x]['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");
				while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
					$selected_attribute = false;
					$products_options_array = array();
					$lc_text .= '<tr><td class="main">' . $products_options_name['products_options_name'] . ':</td><td>' . "\n";
					$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $listing[$x]['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'");
	$list_of_prdcts_attributes_id = '';
	  $products_options = array(); // makes sure this array is empty again
	while ($_products_options = tep_db_fetch_array($products_options_query)) {
		  $products_options[] = $_products_options;
	  }

  for ($v = 0; $v < count($products_options); $v++) {
	  $options_text = ''; // make it empty again
	  $options_text = $products_options[$v]['products_options_values_name'];
	  if ($products_options[$v]['options_values_price'] != '0') {
		$options_text .= ' (' . $products_options[$v]['price_prefix'] . $currencies->display_price($products_options[$v]['options_values_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) .') ';
	  } 
	  $products_options_array[] = array('id' => $products_options[$v]['products_options_values_id'], 'text' => $options_text);
	}

					$lc_text .= tep_draw_pull_down_menu('id_'.$listing[$x]['products_id'].'[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute);
					$lc_text .= '</td></tr>';
				}
				$lc_text .= '</table>';
			}
			break;	
			case 'PRODUCT_LIST_BUY_NOW_MULTIPLE': 
			$lc_align = 'right'; 
			$lc_valign = 'top'; 
			$lc_text = '<form name="buy_now_' . $listing[$x]['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action','sort')) . 'action=buy_now_form', 'NONSSL') . '">';
			$lc_text .= (TABLE_HEADING_MULTIPLE) . '<input type="text" name="cart_quantity" value="1" maxlength="6" size="4">'; 
	if ((int)$listing[$x]['total'] > 0) {
				$lc_text .= '<table border="0" cellpadding="0" cellspacing"0">'; 
				$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing[$x]['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); 
				while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { 
					$selected_attribute = false; 
					$products_options_array = array();
					$lc_text .= '<tr><td class="main">' . $products_options_name['products_options_name'] . ':</td><td>' . "\n";
					$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $listing[$x]['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'");
	$list_of_prdcts_attributes_id = '';
	  $products_options = array(); // makes sure this array is empty again
	while ($_products_options = tep_db_fetch_array($products_options_query)) {
		  $products_options[] = $_products_options;
	  }

  for ($v = 0; $v < count($products_options); $v++) {
	  $options_text = ''; // make it empty again
	  $options_text = $products_options[$v]['products_options_values_name'];
	  if ($products_options[$v]['options_values_price'] != '0') {
		$options_text .= ' (' . $products_options[$v]['price_prefix'] . $currencies->display_price($products_options[$v]['options_values_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) .') ';
	  } 
	  $products_options_array[] = array('id' => $products_options[$v]['products_options_values_id'], 'text' => $options_text);
	}

					$lc_text .= tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); 
					$lc_text .= '</td></tr>'; 
				} 
				$lc_text .= '</table>'; 
				$lc_text .= '<br>' . tep_draw_hidden_field('products_id', $listing[$x]['products_id']) . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing[$x]['products_name'] . TEXT_NOW);

			} // end if ((int)$listing[$x]['total'] > 0)
			if ((int)$listing[$x]['total'] == 0) { 
				$lc_text .= '<br>';
				$lc_text .= '<br>' . tep_draw_hidden_field('products_id', $listing[$x]['products_id']) . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing[$x]['products_name'] . TEXT_NOW);
				$lc_text .= '<table border="0" cellpadding="0" cellspacing"0"><tr><td class="main"></td></tr></table>';
			}
			$lc_text .= '</form>'; 
			break; 
			// End Add Multiple mod
		}
		$product_contents[] = $lc_text;
	}
	$lc_text = implode('<br>', $product_contents);
	$list_box_contents[$row][$column] = array('align' => 'center',
											//bof product listing with attributes
											'valign' => $lc_valign,
											//eof product listing with attributes
											//2.2 modification ,add width in td
										  'params' => 'class="productListing-data" width="'.$tdsize.'%"',
										  'text'  => $lc_text);

	$column ++;

	if ($x == ($no_of_listings -1)) {
		$last_column = ($x % PRODUCT_LIST_NUMCOL); // x modulus number of columns
		//BOF version 2.2 modification
		// fill up the remainder of the table row with empty cells
		for ($column = ($last_column + 1); $column < $colnum; $column++) {
			$list_box_contents[$row][$column] = array('align' => 'center',
											//bof product listing with attributes
											'valign' => $lc_valign,
											//eof product listing with attributes
											//2.2 modification ,add width in td
										  'params' => 'class="productListing-data" width="'.$tdsize.'%"',
										  'text'  => " ");
		}
	} 

	if ($column >= $colnum && $x < ($no_of_listings -1)) {
		$row ++; // we start a new tr here  with $list_box_contents unless we already listed all products
		// $list_box_contents[$row] = array('params' => $class_for_buy_now);
		$column = 0;
  $counter++; // counter only goes up after the buy now buttons have been outputted, counts the real rows
  if ($use_tr_for_buy_now_button == true) {
  // make sure all data cells per row are filled
  $last_column = sizeof($buy_now_button_array);
  for ($zz = $last_column; $zz < PRODUCT_LIST_NUMCOL; $zz++) {
	$buy_now_button_array[] = " ";
  }
  $list_box_contents[$row] = array('params' => $class_for_buy_now_row);
  foreach ($buy_now_button_array as $column1 => $lc_text1) {
	$list_box_contents[$row][$column1] = array('align' => 'center',
										   'params' => 'class="productListing-data"',
										   'text'  => $lc_text1);
  }
 unset($buy_now_button_array);
 $row ++;
  } // end if ($use_tr_for_buy_now_button == true)
// output the last row with buy now buttons if needed
	} elseif ($x == ($no_of_listings -1) && $use_tr_for_buy_now_button == true) { 
		$row ++; // we start a new tr here with $list_box_contents for the last row with buy now buttons
  // make sure all data cells per row are filled
  $last_column = sizeof($buy_now_button_array);
  for ($zz = $last_column; $zz < PRODUCT_LIST_NUMCOL; $zz++) {
	$buy_now_button_array[] = " ";
  }
  $list_box_contents[$row] = array('params' => $class_for_buy_now_row);
  foreach ($buy_now_button_array as $column1 => $lc_text1) {
	$list_box_contents[$row][$column1] = array('align' => 'center',
										   'params' => 'class="' . $class_for_buy_now . '"',
										   'text'  => $lc_text1);
   }
   unset($buy_now_button_array);
} // end elseif ($x == ($no_of_listings -1) && $use_tr_for_buy_now_button == true)
} // end for ($x = 0; $x < $no_of_listings; $x++)

new productListingBox($list_box_contents);

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

new productListingBox($list_box_contents);
}

 if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
 <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
 <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
</tr>
<?php if ($add_multiple == true){
?>
 <tr> 
<td align="left" class="main"> </td>
<td align="right" class="main"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); // added end of form here 
?></form></td> 
 </tr> 
<?php } ?>
</table>
<?php
 }
}
?>

 

Thanks for looking

 

Nacman

Link to comment
Share on other sites

Can anyone tell me what might be causing this. I found it by accident while I was working on some formatting ideas.

The code below will show it correctly but basically, on the last row of the BUY NOW TABLES

on a product listing page I get a double CLASS reference. It does not double reference on

any other table. Feel free to have a look at the whole page by visiting my website, but this should suffice.

Yes, that is a bug. The code around line 354-364 reads:

	  $list_box_contents[$row] = array('params' => $class_for_buy_now_row);
  foreach ($buy_now_button_array as $column1 => $lc_text1) {
	$list_box_contents[$row][$column1] = array('align' => 'center',
										   'params' => 'class="' . $class_for_buy_now . '"',
										   'text'  => $lc_text1);
   }
   unset($buy_now_button_array);
} // end elseif ($x == ($no_of_listings -1) && $use_tr_for_buy_now_button == true)
} // end for ($x = 0; $x < $no_of_listings; $x++)

new productListingBox($list_box_contents);

But the 'params' => 'class="' . $class_for_buy_now . '"', should just be: 'params' => $class_for_buy_now, like:

	  $list_box_contents[$row] = array('params' => $class_for_buy_now_row);
  foreach ($buy_now_button_array as $column1 => $lc_text1) {
	$list_box_contents[$row][$column1] = array('align' => 'center',
										   'params' => $class_for_buy_now,
										   'text'  => $lc_text1);
   }
   unset($buy_now_button_array);
} // end elseif ($x == ($no_of_listings -1) && $use_tr_for_buy_now_button == true)
} // end for ($x = 0; $x < $no_of_listings; $x++)

new productListingBox($list_box_contents);

Link to comment
Share on other sites

Thanks again JanZ....That fixed it. Do you have any ideas why the "add to cart" buttons bring me to product_info instead of just adding it to my infobox cart box on the left of my page. I only want the product_info to come up when they click the pics or the name of the product.

 

I tried changing the action from buy_now to add_product but that messed things up upon return to the product page.

 

Nac

Link to comment
Share on other sites

Do you have any ideas why the "add to cart" buttons bring me to product_info instead of just adding it to my infobox cart box on the left of my page.

Normally, application_top does that when it finds out that a product has attributes. It then re-directs straight to product_info.php to choose those. If there are none things should be normal I guess.

Link to comment
Share on other sites

Jan,

 

I am still struggling with the multi columns. I backed out the DJmonkey old contribution and added the one you just updated in December. I'm getting two errors

 

Warning: Division by zero in /home/infinity/public_html/catalog/includes/modules/product_listing_col.php on line 139

 

Warning: Division by zero in /home/infinity/public_html/catalog/includes/modules/product_listing_col.php on line 299

 

My admin setting are:

 

Display Buy Now column 0 Info

Display Category/Manufacturer Filter (0=disable; 1=enable) 1 Info

Location of Prev/Next Navigation Bar (1-top, 2-bottom, 3-both) 3 Info

Display Add Multiples column 0 Info

Display Add Multiples with Buy Now column 3 Info

Number of column per row 0

 

ARRGGG! Where did I go wrong with this? Also, it is still showing products underneath the errors and I am still not getting my group pricing to show with the attributes but it is going into the cart with the correct price.

 

Please please take pity on me - I'm so frustrated!! This is the only thing standing in my way to go live at this point :(

 

Thanks so much!

 

joanne

Link to comment
Share on other sites

  • 3 weeks later...
Hi,

 

Please, please, please: I really need help with the split page. My links redirecting to page 2, 3, 4 and Next do not work.

 

They do work with the new products page in row but not with the Products Listing in Columns.

 

I don't know what to do... I have had a look at page_split_results but I can't see nothing wrong but then again I don't know anyting about codes.

 

But surely it can't be a page_split problem if the new products page works fine?...

 

I would be very very grateful if someone could point me in the right direction.

 

Florence

 

I'm having the same problem. Did you ever get an answer?

Link to comment
Share on other sites

I'm having the same problem. Did you ever get an answer?

Don't know, I never saw her post till today anyway.

 

It looks (line numbers are not exactly right I think) to be connected to the variable that sets the number of columns: PRODUCT_LIST_NUMCOL

 

The instructions tell you to add it to the database (plus a number of other ones):

 

INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Number of column per row', 'PRODUCT_LIST_NUMCOL', '3', 'How many columns per row to display?', '8', '13', now());

However, you can also add it as a define in the top of product_listing_col.php of course:

define('PRODUCT_LIST_NUMCOL', '3');

Link to comment
Share on other sites

Hi!

I wonder if someone know how to write in product_listing_col.php so if the quantity is 0 it should not display the buy now button before i installed this contrib i had it so in product_listing.php but i cant get it to work with this contrib.

Anyone have a qlue?

 

Regards Tony

Link to comment
Share on other sites

I wonder if someone know how to write in product_listing_col.php so if the quantity is 0 it should not display the buy now button before i installed this contrib i had it so in product_listing.php but i cant get it to work with this contrib.

Shouldn't be much of a difference. Either change the query to add products_stock to it or use the example of the specials query to query the stock for all the products and add it to the "mix".

 

Then (if you don't use the attributes) change the code here (around line 195) to output something different depending on stock:

				//bof product listing with attributes
			case 'PRODUCT_LIST_BUY_NOW':
	// this button will be in a separate table row for better aligning
	  $buy_now_button_array[] = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action','sort')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW, 'style="padding-top: 5px;"') . '</a> ';
	  $lc_text = ''; // otherwise the previous $lc_text will be outputted again 
			break;

Link to comment
Share on other sites

Alright so this should be an easy one, I have added this contribution and it works great. The only problem I have is with the order of the products being displayed in a category. If i look in my index.php file it says my site is set to list by 'PRODUCT_LIST_NAME' but my products are listed by date added with the most recent product added being the last product displayed. This is the opposite of what i want. I have tried changing my index.php to list by manufacture or asc. insted of desc. order nothing seems to change this. I am sure there is somthing stupid i am missing but cant seem to figure out what it is. It seems some others have this problem but nobody answers. any help?

Link to comment
Share on other sites

Alright so this should be an easy one, I have added this contribution and it works great. The only problem I have is with the order of the products being displayed in a category. If i look in my index.php file it says my site is set to list by 'PRODUCT_LIST_NAME' but my products are listed by date added with the most recent product added being the last product displayed. This is the opposite of what i want. I have tried changing my index.php to list by manufacture or asc. insted of desc. order nothing seems to change this. I am sure there is somthing stupid i am missing but cant seem to figure out what it is. It seems some others have this problem but nobody answers. any help?

Why do you think this is an easy one if you found so many posts that nobody answered? Perhaps not so easy?

 

Actually, the order is listing by products_name if no GET variable with sort is found and PRODUCT_LIST_NAME is shown in the product listing. If you don't have the products_name used in your display of the products, you have to hack the index.php to use it anyway:

	if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('^[1-8][ad]$', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
  // for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
	// if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
	//  $HTTP_GET_VARS['sort'] = $i+1 . 'a';
	  $listing_sql .= " order by pd.products_name";
   //   break;
   // }
 //  }
} else {
  $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);
  $sort_order = substr($HTTP_GET_VARS['sort'], 1);

And no, this wasn't an easy one. But then you perhaps use the products name and then I would wrong with my guess.

Link to comment
Share on other sites

Why do you think this is an easy one if you found so many posts that nobody answered? Perhaps not so easy?

 

Actually, the order is listing by products_name if no GET variable with sort is found and PRODUCT_LIST_NAME is shown in the product listing. If you don't have the products_name used in your display of the products, you have to hack the index.php to use it anyway:

	if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('^[1-8][ad]$', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
  // for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
	// if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
	//  $HTTP_GET_VARS['sort'] = $i+1 . 'a';
	  $listing_sql .= " order by pd.products_name";
   //   break;
   // }
 //  }
} else {
  $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);
  $sort_order = substr($HTTP_GET_VARS['sort'], 1);

And no, this wasn't an easy one. But then you perhaps use the products name and then I would wrong with my guess.

 

Thanks Jan works great. I didn't mean to understate the difficulty of fixing the sort. I thought it would be as simple as a toggle in the admin panel or at most changing a word or to in the index.php file. I guess thats why i am the newbie and you are the pro. Thanks again.

Link to comment
Share on other sites

Hi, very very great contrib! It's really that I need.

 

Only one question:

I've installed and customised the contrib, some table and other little stuff. Now I've 3 column and 2 row, so I can view max 6 product for page.

 

But if I've one category, with less than 6 product, for ex 1 or 2, this product stay aligned to the left and the last td of the row is empty.

 

So, ther's any way to normalize the space for the td?

 

I mean, ther's 3 column (or how much is set up in che admin side) ok?So If the category have 3 product (3/3 = 1) the space is 100/3

$colnum = PRODUCT_LIST_NUMCOL;

$tdsize = floor(100/PRODUCT_LIST_NUMCOL);

but if I've 5 product (5/3 = 1.6666...) so the space for the frist row (1.666, and this's less than 2 (or whatever is write down in admin side) is 100/3, and the second line (5-3 products on the first line = 2 remain products) is 100/2

 

somethink like this :-D

 

Any idea?

 

Tnx, Jo

Link to comment
Share on other sites

I've installed and customised the contrib, some table and other little stuff. Now I've 3 column and 2 row, so I can view max 6 product for page.

 

But if I've one category, with less than 6 product, for ex 1 or 2, this product stay aligned to the left and the last td of the row is empty.

 

So, ther's any way to normalize the space for the td?

 

I mean, ther's 3 column (or how much is set up in che admin side) ok?So If the category have 3 product (3/3 = 1) the space is 100/3

 

but if I've 5 product (5/3 = 1.6666...) so the space for the frist row (1.666, and this's less than 2 (or whatever is write down in admin side) is 100/3, and the second line (5-3 products on the first line = 2 remain products) is 100/2

Very interesting math you post but it totally doesn't make any sense to me.

Link to comment
Share on other sites

Very interesting math you post but it totally doesn't make any sense to me.

 

lol...

 

ok, I try

 

Ther's any way to have always the row products centered? Any kind of control to add in the admin side

 

for example 2 row and 3 colums, 6 space for the products, now imagine that I've 4 products, the contrib sut up the laylout like this:

 

1 - 2 - 3

4 - e - e

 

Where e = empty

 

Now I wish 1 layout like this:

 

1 - 2 - 3 <- in this row the td space is 33%

4 <- in this row the td space is 100%

 

And for example if I've 5 products? The layout is:

 

1 - 2 - 3 <- in this row the td space is 33%

4 - 5 <- in this row the td space is 50%

 

And for example if I've 2 products the layout is:

 

1 - 2 <- in this row the td space is 50%

 

I hope that I've explained myself

 

:-D

Link to comment
Share on other sites

Ther's any way to have always the row products centered? Any kind of control to add in the admin side.

No. Each product is in it's own table cell (td). In a table, that is in a grid. You can make a td span 2 or more columns, but you are still held to the grid. You can't make a td span 1.5 columns.

Link to comment
Share on other sites

Great contribution - is there a way to order the display of products? I only have 6 products in each category.

 

I'm currently displaying them in 2 rows, with 3 items per row.

 

Is there a way to change the order of the items that are displayed? I have a few items that I'd like to display first.....Is this possible?

 

Thanks

Link to comment
Share on other sites

I have a similar question to Chryses– Does anyone know how to add a phantom (as in empty) row in at the top of the product listing table so that it forces the cells to left align when there are only two products in a row that normally holds four?

 

I have the products listed in rows of 4 columns:

 

X X X X

X X X X

 

But when there are only two items in a category, it spaces them out too far (since it splits it 50%):

 

X_X_

 

If there was an empty row of 4 <th>'s up top (with a with a CSS height:1px or something), a category with only two items would be forced to align left:

 

____

XX

 

I just can't figure out how to add that row in since the table is being dynamically generated by the tablebox() function. I hope this all makes sense. :)

 

Here's the product category page of the site I'm talking about (please delete the two spaces, I just did that to keep the site out of Google searches until it's done):

 

http://en vym eforever.com/index.php?cPath=21

 

Thanks!

Link to comment
Share on other sites

Here's the product category page of the site I'm talking about (please delete the two spaces, I just did that to keep the site out of Google searches until it's done):

Looks like you are using an older version. In the later ones the empty cells are (or are supposed to be) filled with empty td's. Whether all browsers will honor the 25% and align them left with only two products... I don't know. Otherwise make sure that the empty cells get filled not with a no-break-space (as the code does) but a pixel gif you set to the width of your pictures.

Link to comment
Share on other sites

Looks like you are using an older version. In the later ones the empty cells are (or are supposed to be) filled with empty td's. Whether all browsers will honor the 25% and align them left with only two products... I don't know. Otherwise make sure that the empty cells get filled not with a no-break-space (as the code does) but a pixel gif you set to the width of your pictures.

 

 

Yikes, I realize I must have accidentally downloaded a similar, yet not quite as sophisticated version of your plugin:

 

http://www.oscommerce.com/community/contributions,858

 

Thanks for the help, I'm going to attempt to override what I've done so far. We'll see how that goes... :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...