3

In the Message module, why does the following dynamic token validate nicely [message:field-message-content:body] but the single-use (harcdoded) token does not @{message:field-message-content:body}

Basically changing [token] to @{token} doesn't work.

Note: I know I have to create a new message and just can't change the template on the fly to back-propagate existing messages.

For reference from the module's readme.txt:

Tokens

  • "Dynamic" tokens When defining a message type, it is possible to use Drupal tokens in any of the message fields, in order to inject certain content into the field on the fly. E.g. Entering the string "[current-date:short]" to the message text will display the current request time instead of the token. E.g. [message:user:mail] will be replaced with the message author's username (When displaying the message). If the message has fields (e.g field_node_ref), its contents will accessible by the token system as well under [message:field_node_ref]. (For instance: [message:field_node_ref:title]). This relies on "Entity token" module that ships with Entity API. Enabling "Token" module is also recommened, as it provides more tokens and shows a token browser in the message type creation page.

  • "Single use" tokens The single-use tokens are similiar to the dynamic tokens, excepet they're being replaced by their content as the message is created; Meaning this content will not get updated if it's reference gets changed. E.g. "@{message:user:name}" - Will be replaced by the message author's name (When creating the message).
    You can use this for example when you know the user's name is not going to change, so there is no reason for re-checking all the time the user name -- hardcoding it makes more sense.

Note: There is nothing in the error logs. Essentially when I use the dynamic token, it works and if I change it to a hardcoded token, then it doesn't. Basically changing [token] to @{token} it no longer works. I know I have to create a new message and just can't change the template too.

  • can you provide any more information please? any error message? logs? – Alex Weber Jan 7 '14 at 19:45
  • Nothing in the error logs. Essentially when I use the dynamic token, it works and if I change it to a hardcoded token, then it doesn't. Basically changing [token] to @{token} it no longer works. I know I have to create a new message and just can't change the template too. – Nigel Waters Jan 7 '14 at 20:10
  • @Alex, if you have any ideas, I have 21 hours left to award the bounty. If not it gets wasted. :( – Nigel Waters Jan 14 '14 at 22:10
  • oh boy, gold rush is on! – Alex Weber Jan 14 '14 at 23:25
  • :) big. big money on the line. lol – Nigel Waters Jan 14 '14 at 23:28
0

Provided you're using Rules to send the message, i'll suggest you to manually save the message entity after having set all required fields but right before sending the message.

Single Use token are evaluated at save time.

  • The problem is not in rules. The actual message entity doesn't save the token. I have a body field and basically changing [node:body] to @{node:body} doesn't work. – Nigel Waters Jan 16 '14 at 17:47
-3

"Single use" tokens may saved to database one time and not be changed when update relate entity,while "Dynamic" tokens was replace when theme the message.

  • 1
    My question was not, "What is the difference between the two?", but "Why does one validate and the other doesn't?" – Nigel Waters Dec 31 '13 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.