3

我在 Magento CE 1.7.0.2 中添加了一个新产品。我在简短描述属性中输入了 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>
4

1 回答 1

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

于 2016-01-08T16:13:19.593 回答