Node Tokens not replaced by values in emails

Created on 21 July 2023, over 1 year ago
Updated 23 October 2023, over 1 year ago

Hello, thanks so much for this useful module.

I've been trying to send some emails however having some trouble with tokens.

Tokens such as [node:body] are not replaced with their values in sent emails. Tokens made by the View Send module are working.

Steps to reproduce

Create a view and email from content following the docs.
In the email message section, add some tokens like [node:body], [node:title] into the fields. e.g

----
Dear [views-send:name], 

[node:body] 

(inline image of a dog, with alt text of 'dog')

Thanks team 

[node:field_files]

----

The email looks like this on delivery, tokens as is.

----
Dear Test
[http://test-d9.lndo.site/members/test-member],

[node:body]

[dog] (only alt text shows)

Thanks team
[node:field_files]
----

When sending the message, I have 'Send directly using the Batch API' checked. I've tried using different combinations of the MIMEmail and Postmark modules for formatting and sending and changing the text format to Full HTML, Basic HTML, Plain text etc.

The tokens provided by view send, the [views-send:name] and [views-send:email], are working.
Maybe I'm not understanding how the view for the view send should work. Do I need to add the node somehow? I have tried this but couldn't see any node or content fields available in 'relationships', contextual filters or the regular filter fields.
I'm using Drupal 9.5.7

Any help would be greatly appreciated as the tokens is the only thing left I need to complete a project.

Thank you.

💬 Support request
Status

Postponed: needs info

Version

2.0

Component

Tokens

Created by

🇳🇿New Zealand dominictaylor

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @dominictaylor
  • 🇳🇿New Zealand dominictaylor

    I have found a workaround for this using another module.

    1. Install https://www.drupal.org/project/views_field_view . You can use this to embed a view within a view.
    2. Create a view, e.g "Node Tokens View" which filters for the content type and by the ID of the node in the url. Select the fields you want and make it display on the content type you're wanting.
    3. Create a Views Send View block, and embed the Node Tokens View. Make it hidden if you like.
    4. Now you can access the Node Tokens View content as a token in the Views Send View Block.

    This has worked for text type fields and adds a link for attachments to their url. If I can rewrite the url I think I can get the attachments to show up in the email too.

  • Assigned to hansfn
  • 🇳🇴Norway hansfn

    I get reports about the opposite problem, but I'll look into this - this week.

    PS! Please consider trying to reproduce the problem with Drupal 10.

  • 🇳🇴Norway hansfn

    I can't reproduce this - tested for D9 and D10.

    Is the view a page or a block? I normally only creates pages when I want to send e-mail.

    The work-around was very tedious :-) What tokens do you use for the "Now you can access the Node Tokens View content as a token in the Views Send View Block." step?

  • Status changed to Postponed: needs info over 1 year ago
  • 🇳🇿New Zealand dominictaylor

    Hi hansfn,

    The Node Tokens View and the Views Send View were blocks. The Views Send View block only shows on a content type, "Event" because I wanted to get data from it and send it via the Views Send module. Yes, it was tedious, but it worked! The token values were for the node body and title, I can't recall what the name for them was.

    But, to be honest, I should say, I ended up finding a different solution using Webform. I mention this in case anyone else has a similar problem, maybe that would help them, ( feel free to contact me if you do).

    If you like I can recreate the problem to get more information?

  • 🇳🇴Norway hansfn

    I think I know what is going on - your views doesn't have nodes as the base table. (Are you listing users or nodes?) Could you attached the view defintion (yaml file)? Export configuration and find the correct yaml file in the sync directory or whatever it is named.

    I recently made an improvement that enable you to use node or user tokens when a nodes or user relationships is used in the view, by adding "Content ID" (nid) or "User ID" (uid) as a (hidden) field in the view. Please try the dev release .

Production build 0.71.5 2024