Skip to main content

How to remove <br /> added by magento.

In case you're wondering why your product description is all spaced out, then that's because magento is adding automatic line breaks into the content description area...

To get rid of it... look for

nl2br

specifically in description.phtml you'll see

<div class="std">
    <?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($this->getProduct()->getDescription()), 'description') ?>
</div>

it should look like this after you take the nl2br out:

<div class="std">
    <?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), ($this->getProduct()->getDescription()), 'description') ?>
</div>

Comments

Thanks for the tip...

Thanks for the tip...

very useful!

thanks for this useful post! i fix the problem,it looks pretty good now!
thanks again!

It simply doesn't work! I

It simply doesn't work! I tried to remove that part of the code and it is still the same. Still having 's in every description!

Problem Fixed! (Note: DIDN'T

Problem Fixed! (Note: DIDN'T CHANGED ANYTHING IN THE .PHP FILE or ANYWHERE ELSE AS BEING SUGGESTED IN MANY PLACES)

Went to in Admin

In Catalog>Attributes>Manage Attributes look for "Description" and "Short Description" attributes. Once in look for "Enable WYSIWYG" option and select "Yes".

That's it!

(The above suggestions with the code editing, etc. may work if you do not have any attributes installed. If you do, don't bother.)

If that removes the generated

If that removes the auto-generated line breaks in code while inputing custom/advanced HTML, then that would work.

However, with your suggestion, enabling the WYSIWYG editor, logic would state that would only make things worse--i.e. one would turn off the the WYSIWYG editor to do hand coded (custom) HTML, not turn it on. WYSIWYG does exactly what this suggestion is trying to prevent, it automatically ads HTML line breaks/paragraphs during carriage returns.

btw, you have to make sure

btw, you have to make sure you're editing the currently used theme.

Thanks, works perfectly!

Thanks, works perfectly!

Post new comment

The content of this field is kept private and will not be shown publicly.