Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

full description in product listing


sagit

Recommended Posts

Posted

If you want to show a full description in product listing you have to do:

firstly:

install a contribution : http://oscommerce.sunsite.dk/contributions...g_MS2_v.2.5.zip

 

secondly

Change in admin :

product listing/Length of Truncated Product Description to 100000 characters.

and product listing/display image to 1 and product listing/description to 99

 

thirdly: open file "product_listing.php" from /includes/modules ;

find the line that contains : osc_trunc_string string and add any html tags that you want to display properly, for ie: <br> <input> and that is almost all. there is a sample code below from my site:

 

// Products Description Hack begins

case 'PRODUCT_LIST_DESCRIPTION':

$lc_text = '<div class="zawartosc"> ' . osc_trunc_string(strip_tags($listing['products_description'], ' <a><b><br><em><font><i><s><span><strong><sub><sup><u><input>'), PRODUCT_LIST_DESCRIPTION_LENGTH) . ' </div> ';

 

note: html tags marked as red.

 

As i've just written, it is almost done. But you can add some nice css functions called overflow. It keeps contains in specified dimensions. There is a <div> tag above marked as blue. Thanks to it my product description is always in the same table, which keeps listing in trim . So you should create a new class in your stylesheet.

 

Open a stylsheet.css , it is in main catalog folder and add a new class :

 

.productdescription{

width: 355px;height:145px; overflow: auto; align: left;

}

 

 

your code should look similar to this:

// Products Description Hack begins

case 'PRODUCT_LIST_DESCRIPTION':

$lc_text = '<div class="productdescription"> ' . osc_trunc_string(strip_tags($listing['products_description'], '<a><b><br><em><font><i><s><span><strong><sub><sup><u><input>'), PRODUCT_LIST_DESCRIPTION_LENGTH) . ' </div>

';

 

how does it look?

Here is an example:

full_description.jpg

 

Have nice day and ....night!

Simon

  • 4 weeks later...
Posted

hello simon,

first of, i would to thank you for this great contrfibution. however, i could not get to the result as shown here

all i have got was the default details shown but with the descriptions of every items. instead of having them displayed in rows like in the example you provided, i have mine in colomn.

could you please tell me what i have done wrong? i have been looking for this contribution for quite a while.

many thanks.

Posted

Good addon... however I think it can be improved with a few little additions.

 

In general.php

 

// ################### Products Description Hack begins ##############
//
// grabs a length from a string, but goes back to the last space if it cut into
// the middle of a string.  If the string is longer than that, cut, then add '...'
// to the end of the string, if the $more == 1
function osc_trunc_string($str="",$len=150,$more=1)
{
 if ($str=="") return $str;
 if (is_array($str)) return $str;
 $str = trim($str);
 // if it's les than the size given, then return it
 if (strlen($str) <= $len) return $str;
 // else get that size of text
 $str = substr($str,0,$len);
 // backtrack to the end of a word
 if ($str != "") {
	 // check to see if there are any spaces left
	 if (!substr_count($str," ")) {
   if ($more) $str .= "...";
   return $str;
	 }
	 // backtrack
	 while(strlen($str) && ($str[strlen($str)-1] != " ")) {
   $str = substr($str,0,-1);
	 }
	 $str = substr($str,0,-1);
	 if ($more) $str .= "...";
 }
 return $str;
}
// ########### Products Description Hack ends #############

 

Changed to

 

// ################### Products Description Hack begins ##############
//
// grabs a length from a string, but goes back to the last space if it cut into
// the middle of a string.  If the string is longer than that, cut, then add '...'
// to the end of the string, if the $more == 1
function osc_trunc_string($str="",$len=150,$more=1)
{
 if ($str=="") return "<i>$str</i>";
 if (is_array($str)) return "<i>$str</i>";
 $str = trim($str);
 // if it's les than the size given, then return it
 if (strlen($str) <= $len) return "<i>$str</i>";
 // else get that size of text
 $str = substr($str,0,$len);
 // backtrack to the end of a word
 if ($str != "") {
	 // check to see if there are any spaces left
	 if (!substr_count($str," ")) {
   if ($more) $str .= "...";
   return "<i>$str</i>";
	 }
	 // backtrack
	 while(strlen($str) && ($str[strlen($str)-1] != " ")) {
   $str = substr($str,0,-1);
	 }
	 $str = substr($str,0,-1);
	 if ($more) $str .= "...";
 }
 return "<i>$str</i>";
}
// ########### Products Description Hack ends #############

 

This makes the text itilacs

 

I thought it was nice, now I just have to make the products bold

Posted

Wasn't it easier to put <i> just after a div tag and </i> before </div>?

------------

$lc_text = '<div class="zawartosc"><i> ' . osc_trunc_string(strip_tags($listing['products_description'], ' <a><b><br><em><font><i><s><span><strong><sub><sup><u><input>'), PRODUCT_LIST_DESCRIPTION_LENGTH) . ' </i></div> ';

----------------

 

simon

Archived

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

×
×
  • Create New...