2012-03-07 92 views
2

这可能是大多数很简单...剥离HTML标签在Magento

我在Magento的这条线是什么职位,以Pinterest的一部分。

<?php echo urlencode($_product->getShortDescription()) . " $" . urlencode(number_format($_product->getPrice(),2)); ?> 

某处在此,我需要尽可能简短的描述采用了所见即所得的编辑器,并随后将标签添加到数据库剥离标签,我相信我所需要插入到上面是以下(如Magento的有这个功能已经): -

$this->stripTags 

请任何人都可以建议如何能正确添加到上面没有它打破了页面?让我知道是否需要进一步提供任何东西。

在此先感谢。

回答

7

此使用PHP的内置函数strip_tags的和应该工作:

<?php echo urlencode(strip_tags($_product->getShortDescription())) . " $" . urlencode(number_format($_product->getPrice(),2)); ?> 

要使用Magento的功能,使用此:

<?php echo urlencode($this->stripTags($_product->getShortDescription())) . " $" . urlencode(number_format($_product->getPrice(),2)); ?> 

虽然这只能工作,如果$这指向一个有效的对象实例“对不起,我不知道Magento的内部结构”

+0

非常好,谢谢Hendrik。 Magento修复版本仍然打破了页面,但使用你的第一个修复与PHP的strip_tags完美的作品。 – zigojacko 2012-03-07 10:33:57

0

由于stripTags函数在所有块和助手中都可用,所以您可以使用

Mage::helper('core')->stripTags($data)