Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Quick and Easy Product Description Line Break Solution


18 replies to this topic

#1 WebsHawaii

  • Community Member
  • 81 posts
  • Real Name:Gary Wells
  • Location:Hawaii

Posted 12 September 2003, 06:05

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

#2 burt

  • Community Sponsor
  • 6,975 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 12 September 2003, 14:58

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

#3 WebsHawaii

  • Community Member
  • 81 posts
  • Real Name:Gary Wells
  • Location:Hawaii

Posted 13 September 2003, 03:40

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?

#4 burt

  • Community Sponsor
  • 6,975 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 13 September 2003, 08:55

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

#5 wizardsandwars

  • Community Member
  • 4,476 posts
  • Real Name:Chris Bradley

Posted 13 September 2003, 12:31

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.

#6 dcjones

  • Community Member
  • 25 posts
  • Real Name:Dereck Jones

Posted 09 January 2004, 23:20

Hi,

Great Tip, works a treat.

Dereck

#7 sesam

  • Community Member
  • 10 posts
  • Real Name:Mo

Posted 06 February 2004, 00:40

Could anyone post an screenshot? :unsure:

#8 Cerberus

  • Community Member
  • 112 posts
  • Real Name:Kevin
  • Location:United Kingdom

Posted 09 February 2004, 14:39

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.

Edited by Cerberus, 09 February 2004, 14:40.


#9 Woody_CRF

  • Community Member
  • 10 posts
  • Real Name:Jonathan

Posted 05 March 2004, 07:26

Where exactly do you put that code? Sorry n00b question...
Just another Squirrel trying to get a nut :D

#10 Woody_CRF

  • Community Member
  • 10 posts
  • Real Name:Jonathan

Posted 05 March 2004, 07:27

Never mind... I found it.. duh!
Just another Squirrel trying to get a nut :D

#11 dannyliem

  • Community Member
  • 120 posts
  • Real Name:danny

Posted 03 April 2004, 16:26

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

am i missing something here?

#12 ecartz

  • Community Member
  • 1,919 posts
  • Real Name:Matt
  • Gender:Male

Posted 04 April 2004, 05:34

dannyliem, on Apr 3 2004, 11:26 AM, said:

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 backup before making changes.

#13 Marlene

  • Community Member
  • 3 posts
  • Real Name:Marlene

Posted 02 August 2004, 03:14

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.

#14 mrsC2003

  • Community Member
  • 131 posts
  • Real Name:Kelley
  • Location:Pittsburgh PA

Posted 08 August 2004, 05:46

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.

#15 Naughtica

  • Community Member
  • 62 posts
  • Real Name:Naughtica
  • Location:USA

Posted 10 September 2004, 17:40

The HTML tag works great..... good idea!

#16 rizk

  • Community Member
  • 1 posts
  • Real Name:Michelle Rizk

Posted 08 June 2006, 15:26

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

:rolleyes: :o

#17 John Pope

  • Community Member
  • 83 posts
  • Real Name:John Pope

Posted 10 August 2006, 09:59

View Postrizk, on Jun 8 2006, 05:26 PM, said:

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

#18 shaytaan

  • Community Member
  • 185 posts
  • Real Name:Adam

Posted 10 August 2006, 16:14

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/>?
¸,ø¤°`°¤ø,¸© God must love stupid people, he made so many ©¸,ø¤°`°¤ø,¸

#19 snuggtopz

  • Community Member
  • 34 posts
  • Real Name:Rich
  • Gender:Male
  • Location:Uk

Posted 11 October 2011, 13:00

<p> works for me