Latest News: (loading..)

Archived

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

WebsHawaii

Quick and Easy Product Description Line Break Solution

19 posts in this topic

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

Share this post


Link to post
Share on other sites

Good work. Take a look at www.php.net/nl2br (which is basically an inbuilt php function that does exactly what your function does).

 

hth

Share this post


Link to post
Share on other sites

If it was so easy then how come no one else posted it? And why when I asked for help regarding this everyone directed me to install a wysiwyg contrib?

Share this post


Link to post
Share on other sites

Maybe your question was not understood the first time you asked. Maybe the person who answered knows little. Maybe maybe maybe. Does it matter ?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

 

am i missing something here?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

I was having the same problem, until I replaced </br> with <br>. Tested in firefox and IE5, seems to work fine.

 

:rolleyes: :o

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

I use Easypopulate for inserting products, and I copy product desc. from a text file which has lines and paragraphs. Will this code make a <b/>?

Share this post


Link to post
Share on other sites