Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Quick and Easy Product Description Line Break Solution


Guest

Recommended Posts

Here is what I did in regards to the line break issue.

 

The issue that I had was in regards to how product_info.php displayed the description of the item. I would not display any of the line breaks. The suggestions that I have received were install the WYSIWYG contribution but I have made to many mods to the store so that will not work and its to time consuming to install.

 

Here is the solution that I came up with.

 

I created a function that converts n to a <BR> tag.

 

<?php

function nl2p($text) {

$text = ereg_replace("n", "<br>", $text);

return $text;

 

}

 

?>

 

 

and inserted that at about line 115 just above this call

 

($product_info_values['products_description'

 

I then added nlp2 just before it so the desc now looks like this

 

<?php echo nl2p ($product_info_values['products_description']); ?>

 

 

Works like a charm and I thought that I'd pass it along.

 

--Gary

Link to comment
Share on other sites

maybe, lol.

 

 

I also think this is a great little tip. Extremly usefull.

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

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

  • 3 months later...
  • 4 weeks later...

Why not use the built in PHP function nl2br ? :huh:

 

Just use:

 

<?php echo nl2br ($product_info_values['products_description']); ?>

 

No need for new functions then ;)

 

p.s. Burt - only read your post after I posted this - you've already mentioned it I see - sorry.

Link to comment
Share on other sites

  • 4 weeks later...
  • 5 weeks later...

I could not find $product_info_values but only $product_info in the product_info.php

 

am i missing something here?

Link to comment
Share on other sites

I could not find $product_info_values but only $product_info in the product_info.php
Different versions use different names for the variables. In particular, the array $product_info_values was renamed $product_info

 

Hth,

Matt

Always back up before making changes.

Link to comment
Share on other sites

  • 3 months later...

You can use the html tag <P> right in your description when you are typing the description into the admin tool?? The tag will not show up in your description. If it does put the closing tag on it.</P>. I think that accomplishes the same goal??? Maybe I read something wrong.

Link to comment
Share on other sites

Hum, I just use keytext with HTML built in the lines with the stuff you hate to type.

 

Good old HTML.....what ever happen to it? :unsure:

I live in my own little world. But it's OK. They know me here.

Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...
  • 2 months later...
I was having the same problem, until I replaced </br> with <br>. Tested in firefox and IE5, seems to work fine.

 

The correct usage is actually <br /> if you want to be xhtml compliant

Link to comment
Share on other sites

  • 5 years later...

Archived

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

×
×
  • Create New...