产品名称中的 Magento HTML 不起作用
Magento HTML in product name not working
我正在研究主题中的 Magento CE 1.9 rwd
我在产品名称中有 <br>
标签,但产品名称仍然显示为单行。
我已经将 Allow HTML Tags on Frontend 设置为 Yes for name
attribute from Manage attributes.
我如何将 <br>
转换为换行符以便产品名称显示在 2 行上?
在此先感谢您的帮助。
快速修复如下:
分类页:
- Go to the folder/file: /rwd/catalog/product/list.phtml
- Go to line number 54,
更改此代码
<?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?>
至
<?php echo $_helper->productAttribute($_product, nl2br($_product->getName()) , 'name'); ?>
产品视图页面中不存在问题。但是,如果这确实在产品页面中弹出,请执行以下操作。
产品详情页面:
- Go to the folder/file: /rwd/catalog/product/view.phtml
- Go to line number 51,
更改此代码
<?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?>
至
<?php echo $_helper->productAttribute($_product, nl2br($_product->getName()) , 'name'); ?>
查看并告诉我这是否适合您。
乐于助人!
快乐编码...
[编辑此答案]
虽然上面的解决方案是可以考虑的 FIX,但下面是可以修复它的东西。
- Complete CACHE clear by deleting the folders under /var/cache and /var/full_page_cache (Enterprise)
- Run a complete Re-Index by executing the below command or by using System > Index Management
文件夹下的命令/shell/:
php indexer.php --reindexall
我在这里添加答案,因为我无法在评论中正确显示答案。
@泽菲林:
上面尝试过的答案。但我遵循了你建议的方法。
但是我没有直接在核心文件中做任何更改,而是将 app/code/core/Mage/Catalog/Helper/Output.php
从 core
codepool 复制到 app/code/local/Mage/Catalog/Helper/Output.php
到 local
codepool 中。
在 line number 125
上更改了以下条件
if ($attribute->getFrontendInput() != 'price') {
$attributeHtml = $this->escapeHtml($attributeHtml);
}
到
if ($attribute->getFrontendInput() != 'price') {
if($attributeName != 'name') {
$attributeHtml = $this->escapeHtml($attributeHtml);
}
}
我正在研究主题中的 Magento CE 1.9 rwd
我在产品名称中有 <br>
标签,但产品名称仍然显示为单行。
我已经将 Allow HTML Tags on Frontend 设置为 Yes for name
attribute from Manage attributes.
我如何将 <br>
转换为换行符以便产品名称显示在 2 行上?
在此先感谢您的帮助。
快速修复如下:
分类页:
- Go to the folder/file: /rwd/catalog/product/list.phtml
- Go to line number 54,
更改此代码
<?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?>
至
<?php echo $_helper->productAttribute($_product, nl2br($_product->getName()) , 'name'); ?>
产品视图页面中不存在问题。但是,如果这确实在产品页面中弹出,请执行以下操作。
产品详情页面:
- Go to the folder/file: /rwd/catalog/product/view.phtml
- Go to line number 51,
更改此代码
<?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?>
至
<?php echo $_helper->productAttribute($_product, nl2br($_product->getName()) , 'name'); ?>
查看并告诉我这是否适合您。
乐于助人!
快乐编码...
[编辑此答案]
虽然上面的解决方案是可以考虑的 FIX,但下面是可以修复它的东西。
- Complete CACHE clear by deleting the folders under /var/cache and /var/full_page_cache (Enterprise)
- Run a complete Re-Index by executing the below command or by using System > Index Management
文件夹下的命令/shell/:
php indexer.php --reindexall
我在这里添加答案,因为我无法在评论中正确显示答案。
@泽菲林:
上面尝试过的答案。但我遵循了你建议的方法。
但是我没有直接在核心文件中做任何更改,而是将 app/code/core/Mage/Catalog/Helper/Output.php
从 core
codepool 复制到 app/code/local/Mage/Catalog/Helper/Output.php
到 local
codepool 中。
在 line number 125
if ($attribute->getFrontendInput() != 'price') {
$attributeHtml = $this->escapeHtml($attributeHtml);
}
到
if ($attribute->getFrontendInput() != 'price') {
if($attributeName != 'name') {
$attributeHtml = $this->escapeHtml($attributeHtml);
}
}