user550265
user550265

Reputation: 3289

working token_replace example in drupal

I have many tokens of the form

//Email confirmatory message.

Group: [message:group-name]

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?

Upvotes: 1

Views: 1532

Answers (2)

Andreas Frank
Andreas Frank

Reputation: 81

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

Upvotes: 1

kba
kba

Reputation: 1177

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).

Upvotes: 1

Related Questions