Pergunta

This is probably pretty simple for most...

I have this line in Magento which is part of what posts to Pinterest.

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

Somewhere in this, I need to strip tags as the short description uses a WYSIWYG editor and subsequently adds tags to database, I believe what I need to insert to the above is the following (as Magento has this function already):-

$this->stripTags

Please could anyone advise how this can be correctly added to the above without it breaking the page? Let me know if I need to supply anything further.

Thanks in advance.

Foi útil?

Solução

This uses php's builtin function strip_tags and should work:

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

To use Magento's function, use this:

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

though this can only work if $this points to a valid object instance of "something" (sorry, I don't know Magento's internals)

Outras dicas

Since stripTags function is available in all blocks and helpers you can just use

Mage::helper('core')->stripTags($data)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top