开发者

working token_replace example in drupal

I have many tokens of the form

//Email confirmatory message.

Group: [message:group-name]

开发者_Python百科

Author: [message_author:user]

Message: [message:message-body] //html tags are sent in the message body

I need to remove the html tags from the token. For this I wish to use the token_replace() function in drupal. Is there a working example that will help me achieve this?


token_replace just replaces all tokens within a string with the respective substitution. If you need to remove the html tags, you're probably better off checking if such functionality is built in (something along the lines of "send in plain text" or defining another token that does what you want in a custom module).

Apart from this you could replace the html tags with a regular expression (not recommended) or using a PHP library that does this (better, but still not recommended).


Use: drupal_html_to_text() function or html_entity_decode() depending on what you want to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜