4

これはおそらくほとんどの人にとって非常に簡単です...

Pinterest への投稿の一部である Magento にこの行があります。

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

このどこかで、短い説明が WYSIWYG エディターを使用し、その後データベースにタグを追加するため、タグを削除する必要があります。上記に挿入する必要があるのは次のとおりだと思います (Magento には既にこの機能があるため):-

$this->stripTags

ページを壊すことなく、これを上記に正しく追加する方法を誰か教えてください。さらに何かを提供する必要がある場合はお知らせください。

前もって感謝します。

4

2 に答える 2

11

これは、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 ) ); ?>

ただし、これは $this が「何か」の有効なオブジェクト インスタンスを指している場合にのみ機能します (申し訳ありませんが、Magento の内部構造はわかりません)。

于 2012-03-07T10:17:30.357 に答える