Magento editor automatic line break issue while adding new product

旧街凉风 提交于 2019-12-07 18:21:16

问题


I'm adding a new product in Magento CE 1.7.0.2. I entered the HTML code in Short Description attribute.

MY PROBLEM: I really don't know where these extra <br> coming from. Even the WYSIWYG editor is not showing these <br> but they are appearing on the website's product page. Please help.

WHAT I ENTERED:

<p>Product Description:</p>
<table border="1" cellspacing="0" cellpadding="5px">
    <tr>
        <td>Category</td>
        <td>Specials</td>
    </tr>
    <tr>
        <td>Texure</td>
        <td>Digitally Printed on High Quality Matte Paper</td>
    </tr>
</table>

WHAT IT IS DISPLAYING:

<p>Product Description:</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<table border="1" cellspacing="0" cellpadding="5px">
    <tr>
        <td>Category</td>
        <td>Specials</td>
    </tr>
    <tr>
        <td>Texure</td>
        <td>Digitally Printed on High Quality Matte Paper</td>
    </tr>
</table>

回答1:


I have found the answer on this link.




回答2:


These additional breaks are caused by nl2br() function that should be removed.

To resolve this for short description, open app/design/frontend/[package]/[theme]/template/catalog/product/view.phtml, find:

<?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?>

and replace this by:

<?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>

To resolve this for description, open app/design/frontend/[package]/[theme]/template/catalog/product/view/description.phtml, find:

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

and relace this by:

<?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getDescription(), 'description') ?>

Source



来源:https://stackoverflow.com/questions/14718649/magento-editor-automatic-line-break-issue-while-adding-new-product

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!