Magento编辑器在添加新产品时自动换行


Magento editor automatic line break issue while adding new product

我将在Magento CE 1.7.0.2中添加一个新产品。我在Short Description属性中输入了HTML代码。

我的问题:我真的不知道这些额外的<br>是从哪里来的。即使是所见即所得编辑器也没有显示这些<br>,但它们出现在网站的产品页面上。请帮忙。

我输入的内容:

<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>

显示内容:

<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>

这些额外的中断是由应该删除的nl2br()函数引起的。

要解决简短描述中的此问题,请打开app/design/frontend/[package]/[theme]/template/controlog/product/view.phtml,找到:

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

并替换为:

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

要解决描述中的问题,请打开app/design/frontend/[package]/[theme]/template/controlog/product/view/description.html,找到:

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

并通过以下方式进行关联:

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