Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Item Descriptions too short


Kevin360

Recommended Posts

Posted

Wondering if anyone can help me figure this out. When you click the category and the items are shown, my item names appear as it should, as does the photos, but the description is very short and is cut off. I don't expect the full product description to be shown, but is there either a Contrib. that will let me set a specific description, or at least a way to include more of the description. I get about 5.5 words now. I did install a template and figure that's probably why. I'd like to set specific descriptions or at least have a "..." at the end of the short description so it's clear that this continues in the product info.

Posted

The standard version of osCommerce doesn't include product descriptions on the product listing pages so this is added code.

 

I would look in the following file for the added code where you should be able to alter it:

includes/modules/product_listing.php

Posted

Ok, I'm not sure what I'm looking at here... this is the content of my includes/modules/product_listing.php Do you see what could be the issue?

 

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

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<? /*

<?php echo $breadcrumb->trail(' » ')?>

*/?>

		<table border="0" cellspacing="0" cellpadding="0">
			<tr><td class="cont_header_txt"><?php echo $breadcrumb->trail(' » ')?></td></tr>
		</table>	

<? tep_draw_heading_top_3();?>

<?
 $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 == '2') ) ) {
?>
<table border="0" cellspacing="0" cellpadding="0" class="result box_width_cont">
 <tr>
<td><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<td class="result_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 echo tep_draw_result_top(); ?>

<?php
 }
?>
<?
$info_box_contents = array();
 $list_box_contents = array();
$my_row = 0;
$my_col = 0;

 $td_counter = 0;
 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 = '';
	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);
}

$list_box_contents[0][] = array('align' => $lc_align,
								'params' => 'class="productListing-heading"',
								'text' => ' ' . $lc_text . ' ');
 }

 if ($listing_split->number_of_rows > 0) {
$rows = 0;
$listing_query = tep_db_query($listing_split->sql_query);
while ($listing = tep_db_fetch_array($listing_query)) {
  $rows++;

  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 = '';
	   $p_model =  $lc_text = '' . $listing['products_model'] . '';
		break;
	  case 'PRODUCT_LIST_NAME':
		$lc_align = '';
		if (isset($HTTP_GET_VARS['manufacturers_id'])) {
	   $p_name = $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . substr( $listing['products_name'],0,MAX_DESCR_NAME) . '</a>';
		} else {
		 $p_name = $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' .  substr($listing['products_name'],0,MAX_DESCR_NAME). '</a>';
		}
		break;
	  case 'PRODUCT_LIST_MANUFACTURER':
		$lc_align = '';
	   $p_manuf = $lc_text = '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a>';
		break;
	  case 'PRODUCT_LIST_PRICE':
		$lc_align = 'right';
		if (tep_not_null($listing['specials_new_products_price'])) {
		$p_price =  $lc_text = '<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>   <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
		} else {
	   $p_price = $lc_text = '<span class="productSpecialPrice">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
		}
		break;
	  case 'PRODUCT_LIST_QUANTITY':
		$lc_align = 'right';
	   $p_quntity = $lc_text = '' . $listing['products_quantity'] . '';
		break;
	  case 'PRODUCT_LIST_WEIGHT':
		$lc_align = 'right';
		$p_weight = $lc_text = '' . $listing['products_weight'] . '';
		break;
	  case 'PRODUCT_LIST_IMAGE':
		$lc_align = 'center';
		if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		 $p_pic =  $lc_text = '<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 {
		 $p_pic = $lc_text = '<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':
		$lc_align = 'center';
		$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>';
		break;
	}


$product_query = tep_db_query("select products_description, products_id from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$listing['products_id'] . "' and language_id = '" . (int)$languages_id . "'");
  $product = tep_db_fetch_array($product_query);

   	$p_desc = substr($product['products_description'], 0, MAX_DESCR_1);
	$p_id = $product['products_id'];
/*		$list_box_contents[$cur_row][] = array('align' => $lc_align,
										   'params' => '',
										   'text'  => $lc_text); */

}


$info_box_contents[$my_row][$my_col] = array('align' => 'center',
									   'params' => '',
									   'text' => '
		'.tep_draw_prod_top().'
			<table style="height:127px" cellpadding="0" cellspacing="0" border="0" class="product">
				<tr><td style="width:179px;">
					  <table cellpadding="0" cellspacing="0" border="0" style="width:190px;height:125px">
						<tr><td class="pic" style="padding:0px 28px 0px 14px;"><br style="line-height:14px">'.$p_pic.'</td></tr>
					</table>
					</td>
					<td style="width:198px;">
						<table  cellpadding="0" cellspacing="0" border="0">
							<tr><td style="height:55px; vertical-align:middle">
									'.$p_name.'<br>
									<br style="line-height:3px;">
									'.$p_desc.'<br>
							</td></tr>
							<tr><td style="height:23px; vertical-align:middle">
									'.$p_price.'<br>
							</td></tr>
							<tr><td style="height:100%; vertical-align:middle"><br style="line-height:1px;"><br style="line-height:5px;"><a href="' . tep_href_link('product_info.php?products_id='.$p_id) . '">'.tep_image_button("button_details.gif").'</a><br>
									<br style="line-height:4px;">
									<a href="'.tep_href_link("products_new.php","action=buy_now&products_id=".$p_id).'">'.tep_image_button('button_add_to_cart1.gif').'</a><br>
							</td></tr>
						</table>
					</td>
				</tr>
			</table>			
		'.tep_draw_prod_bottom());




$my_col ++;
if ($my_col > 0) {
  $my_col = 0;
	$my_row ++;
}
 }








new contentBox($info_box_contents); 
//	new productListingBox($list_box_contents);
} else {  ?>



<?php echo tep_draw_heading_top_1(); ?>

	<table border="0" cellspacing="1" cellpadding="2" class="infoBox box_width_cont">
	  <tr class="infoBoxContents">
		<td>
			<table cellpadding="0" cellspacing="0" class="product">
				<tr><td class="sea_2"><?php echo TEXT_NO_PRODUCTS ?></td></tr>
			</table>
		</td>
	  </tr>
</table>

<?php

echo tep_draw_heading_bottom_1(); 

 }

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

<?php echo tep_draw_result_bottom(); ?>

<table border="0" cellspacing="0" cellpadding="0" class="result box_width_cont">
 <tr>
<td><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<td class="result_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
 }
?>

Posted

The code you are looking for is:

$p_desc = substr($product['products_description'], 0, MAX_DESCR_1);

 

According to that you can control how many words should be shown in your admin section so login to your admin section and look through every link under Configuration and see if you are able to find it, failing that you could try changing the above line to the line below, changing the added 23 to how many words you need, this hasn't been tested!

 

$p_desc = substr($product['products_description'], 0, '23');

Posted

There is nothing in the configuration that I can see. The code change works... but.. Only works, obviously, for the product description in the product_listing. But there is the new products section and others. Where would the MAX_DESCR_1 be defined and how can I change that? That way I can at least only change it once instead of in each file.

Posted

MAX_DESCR_1 should be defined somewhere in your admin section, most likely somewhere under Configuration

Posted
MAX_DESCR_1 should be defined somewhere in your admin section, most likely somewhere under Configuration

 

I just looked and I don't see it. Maybe we have a different version. If you can look and see where under admin it is, maybe we are just blind.

 

Thanks

Custom PC's, Components, Liquid Cooling, Notebooks and More

Posted
I just looked and I don't see it. Maybe we have a different version. If you can look and see where under admin it is, maybe we are just blind.

 

Thanks

 

Yeah... I've clicked every link and read every description for the different options. I don't see it either... of course I've spent days trying to fix a code that just needed a semicolon... I'm using a purched template off template monster. Is it possible that the code is broken somewhere so that I'm not seeing it in the admins config section? (or anywhere under admin)

Posted

Its possible, only way to see is going through the database, you could make a backup to your computer and open it in notepad and see if you can find it that way, could be quicker.

  • 2 weeks later...
Posted

$p_desc = substr($product['products_description'], 0, MAX_DESCR_1);

 

Ok... so I took the above and changed it to

$p_desc = substr($product['products_description'], 0,55).'...';

 

This gives me plenty of room to to get a good idea of the description and adds a trailing '...' so the shopper knows this text is continued on the next page. Thanks for post of the code to change.

 

Now I have another similar issue. This works great for products.. but not for what's new. I looked through the whats_new.php but couldn't find the code to change. I tried changing a few things... but nothing worked. Any ideas on this?

Posted

Just answered my own questions....

 

I was looking in includes/boxes/whats_new.php

 

I should have been looking in includes/modules/new_products.php

Posted
MAX_DESCR_1 should be defined somewhere in your admin section, most likely somewhere under Configuration

 

 

After looking for over an hour to locate where MAX_DESCR_NAME was defined in order to increase the displayed product name length, i found MAX_DESCR_NAME and MAX_DESCR_1 defined in \catalog\includes\header.php

 

Hope this helps anyone else looking for this in the future.

Archived

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

×
×
  • Create New...