Jump to content



Latest News: (loading..)

- - - - -

Quick and Easy Product Description Line Break Solution


This topic has been archived. This means that you cannot reply to this topic.
18 replies to this topic

#-19   WebsHawaii

WebsHawaii
  • Members
  • 81 posts

Posted 12 September 2003 - 06:05 AM

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

#-18   burt

burt

    Code Monkey

  • Community Team
  • 7,728 posts

Posted 12 September 2003 - 02:58 PM

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

#-17   WebsHawaii

WebsHawaii
  • Members
  • 81 posts

Posted 13 September 2003 - 03:40 AM

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?

#-16   burt

burt

    Code Monkey

  • Community Team
  • 7,728 posts

Posted 13 September 2003 - 08:55 AM

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

#-15   wizardsandwars

wizardsandwars
  • Members
  • 4,476 posts

Posted 13 September 2003 - 12:31 PM

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.

#-14   dcjones

dcjones
  • Members
  • 25 posts

Posted 09 January 2004 - 11:20 PM

Hi,

Great Tip, works a treat.

Dereck

#-13   sesam

sesam
  • Members
  • 10 posts

Posted 06 February 2004 - 12:40 AM

Could anyone post an screenshot? :unsure:

#-12   Cerberus

Cerberus
  • Members
  • 112 posts

Posted 09 February 2004 - 02:39 PM

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 - 02:40 PM.


#-11   Woody_CRF

Woody_CRF
  • Members
  • 10 posts

Posted 05 March 2004 - 07:26 AM

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

#-10   Woody_CRF

Woody_CRF
  • Members
  • 10 posts

Posted 05 March 2004 - 07:27 AM

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

#-9   dannyliem

dannyliem
  • Members
  • 120 posts

Posted 03 April 2004 - 04:26 PM

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

am i missing something here?

#-8   ecartz

ecartz
  • Community Sponsor
  • 1,956 posts

Posted 04 April 2004 - 05:34 AM

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.

#-7   Marlene

Marlene
  • Members
  • 3 posts

Posted 02 August 2004 - 03:14 AM

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.

#-6   mrsC2003

mrsC2003
  • Members
  • 131 posts

Posted 08 August 2004 - 05:46 AM

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.

#-5   Naughtica

Naughtica
  • Members
  • 62 posts

Posted 10 September 2004 - 05:40 PM

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

#-4   rizk

rizk
  • Members
  • 1 posts

Posted 08 June 2006 - 03:26 PM

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

:rolleyes:  :o

#-3   John Pope

John Pope
  • Members
  • 83 posts

Posted 10 August 2006 - 09:59 AM

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

#-2   shaytaan

shaytaan
  • Members
  • 185 posts

Posted 10 August 2006 - 04:14 PM

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 ©¸,ø¤°`°¤ø,¸

#-1   snuggtopz

snuggtopz
  • Members
  • 34 posts

Posted 11 October 2011 - 01:00 PM

<p> works for me