Problem/Motivation

I am trying to use the node token in the email body field as the following screenshot:
issue
But, when I got the email notification the values of tokens are empty.

Steps to reproduce

Add some tokes like [node:nid] [node:title] in the email body and so, when the content being transitioned the notification message bring the token value empty.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
token-does-not-work.png56 KBdanielmme

Comments

danielmme created an issue. See original summary.

danielmme’s picture

danielmme’s picture

Status: Active » Closed (outdated)
ryankavalsky’s picture

Just in case anybody stumbles on this issue again, I solved this by updating the text format's configuration:

  1. Move "Replaces global and entity tokens with their values" to the top of the "Filter processing order" list
  2. Un-check "Replace empty values" under the Filter Settings for "Replaces global and entity tokens with their values"

It looks like when check_markup() is called in \Drupal\content_moderation_notifications\Notification::sendNotification(), the markup is cleaned up based on the Text Format's rules. This function ends up replacing more generic tokens (e.g. [current-page:xxx]), but would strip away the node-based tokens since check_markup() isn't aware of the node's context.

Un-checking "Replace empty values" gives $token_service->replace() a chance to replace the node-based tokens when building the email message when the module calls hook_mail().