So you’re starting to enter in your product descriptions on your Magento site. All’s going pretty well until you go to view your product and you notice that there are tons of extra spaces between your carefully-crafted paragraphs. “I didn’t put those there!” you say to yourself.

Then you do the next logical thing, which is to “Inspect Element”, and you find that there are all these <br> codes in there. So the you go back to your admin panel, and try to find those pesky elements to remove them, only to discover that they’re nowhere to be found! “WTF?!?”

Ok. Here’s the thing: Magento tries to be “smart” and creates these line breaks whenever it sees that you’ve tried to create a paragraph (why? I have no idea, but someone in core Magento development decided it was important enough to create a specific function called nl2br – which is short for New Line 2 Break).

You should be able to fix this fairly easily though, simply by editing your theme files.

  1. Short Description

    Locate your view.phtml file. Usually here: /app/design/frontend/[package]/[theme]/template/catalog/product/view.phtml. Search for…

    productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?>

    And then simply remove the nl2br( and the closing ). now your code will just look like

    productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
  2. Description

    Locate your description.phtml/app/design/frontend/[package]/[theme]/template/catalog/product/view/description.phtml. Search for…

    helper('catalog/output')->productAttribute($this->getProduct(), nl2br($_description), 'description') ?>

    And again, very simply, remove the nl2br( and the closing ). This will leave you with the following:

    helper('catalog/output')->productAttribute($this->getProduct(), $_description, 'description') ?>

That’s it. Pretty simple.

Now, if those changes don’t fix the issue for you, it’s possible that you’re using 3rd party extensions that are overriding your theme files.

But remember to always backup your files before making any changes, and flush your Magento Cache after saving/uploading any changes.

thePixelPixie.com - WordPress boutique

Subscribe and receive my FREE eBook


4 MISTAKES You’re Making on Your Website that are Costing You MONEY!

  • This field is for validation purposes and should be left unchanged.

The Author

Save

Like thePixelPixie on Facebook

Leave a Reply

Your email address will not be published.

Ready to chat about how ThePixelPixie can help?