Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

newlines converted to <br /> in product descriptions
 
Dorgo
Sr. Member
 
Total Posts:  127
Joined:  2008-12-16
 

There are a few threads about this but i think it is quite a problem.

It seems that any newlines in the description field (in catalog_product_entity_text) is run through nl2br before being displayed.

This makes sense if the field is used to enter plain text but does not make sense if entering html. Seeing as the field does accept html then i think there is a problem.

When using a WYSIWYG editor it becomes even more absurd. The editor will already add <br /> for linebreaks (or wrap in <p>) and the displayed description will add another <br /> for each ascii line break (\n).

Someone has suggested using http://www.textfixer.com/tools/remove-line-breaks.php to remove all line breaks but my client can hardly be expected to use that on the source after adding or changing anything with WYSIWYG editor.

I have imported my products automatically with the html from our old site so either i need a fix (instructions to overload so as to not modify the core and keep my mod when there are updates would be great) or a way to strip all newlines from that field in the database (a long way from ideal as it doesn’t cater for future product entry)

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dorgo
Sr. Member
 
Total Posts:  127
Joined:  2008-12-16
 

hmm, looks like i was mistaken but ill put the solution here instead of deleting it in case someone else runs across the same problem.
the offending nl2br is in the view template.

So if your using a WYSIWYG editor or have populated the description fields with html containing line breaks, change
app/design/frontend/default/{YourView}/template/catalog/product/view/description.phtml

nl2br($this->getProduct()->getDescription())
to
$this->getProduct()->getDescription()
 
Magento Community Magento Community
Magento Community
Magento Community
 
Dorgo
Sr. Member
 
Total Posts:  127
Joined:  2008-12-16
 

DP

 
Magento Community Magento Community
Magento Community
Magento Community
 
DirectLowVoltage
Jr. Member
 
Total Posts:  30
Joined:  2009-02-19
 
Dorgo - 03 March 2009 10:38 PM

hmm, looks like i was mistaken but ill put the solution here instead of deleting it in case someone else runs across the same problem.
the offending nl2br is in the view template.

So if your using a WYSIWYG editor or have populated the description fields with html containing line breaks, change
app/design/frontend/default/SolarOnline/template/catalog/product/view/description.phtml

nl2br($this->getProduct()->getDescription())
to
$this->getProduct()->getDescription()

But I don’t have a “app/design/frontend/default/SolarOnline/template/catalog/product/view/description.phtml”

smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dorgo
Sr. Member
 
Total Posts:  127
Joined:  2008-12-16
 

hah. thanks DirectLowVoltage. fixed.

Is ‘view’ the correct terminology?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top