在Magento中剥离HTML标记

zig*_*cko 4 php urlencode strip-tags

这对大多数人来说可能非常简单......

我在Magento有这条线,这是Pinterest发布的一部分.

<?php echo urlencode( $_product->getShortDescription() ) . " $" . urlencode( number_format( $_product->getPrice(),2 ) ); ?>
Run Code Online (Sandbox Code Playgroud)

在这个地方,我需要剥离标签,因为简短描述使用WYSIWYG编辑器,然后将标签添加到数据库,我相信我需要插入上面的内容如下(因为Magento已经有了这个功能): -

$this->stripTags
Run Code Online (Sandbox Code Playgroud)

请问有人可以建议如何在不破坏页面的情况下将其正确添加到上面吗?如果我需要进一步供应,请告诉我.

提前致谢.

Hen*_*ter 11

这使用php的内置函数strip_tags,应该可以工作:

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

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

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

虽然这只能在$ this指向"某事"的有效对象实例时有用(对不起,我不知道Magento的内部)