Cms: Unable to use "globals" in email templates

Created on 9 Sep 2020  路  4Comments  路  Source: statamic/cms

Bug Description

I have created a custom email template to be used in a form. In the footer of this template I would add some company info (like name, phone, ...) using globals.

I have added the tag {{ company:phone }} (company is the Global Set handle) but doesn't output anything in the email.

The same tag in home page works correctly.

How to Reproduce

  1. Create a Global Set (with a handle like settings) with a text field (with a name like foo)
  2. Create an email template: resources/views/vendor/mail/custom-email.antlers.html
  3. Put this string inside the template: The Foo value is: {{ settings:foo }}
  4. Create a new Form and set this template as HTML view
  5. Send an email from this form and check the mail content (it should be The Foo value is:)

Environment

Statamic version: 3.0.7
PHP version: 7.4.9

No addons installed

Install method (choose one):

  • Fresh install from statamic/statamic
enhancement

Most helpful comment

@damcclean opened a PR for this which is on our list to review shortly here. Hang tight!

https://github.com/statamic/cms/pull/2411

All 4 comments

I think this is probably because it's not being parsed as a view, it's just being parsed as a string which means you can't use the cascade (any site variables) and you can't use tags, like the collection ones.

If the gents wanted I could have a go at implementing just the globals data into mail views?

We just don't pass all the same data into the email view that we do into the front-end. But, we can.

Yes please! It would be very useful to pull in globals for social media or contact information.

@damcclean opened a PR for this which is on our list to review shortly here. Hang tight!

https://github.com/statamic/cms/pull/2411

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jcohlmeyer picture jcohlmeyer  路  4Comments

skoontastic picture skoontastic  路  4Comments

filipac picture filipac  路  4Comments

robdekort picture robdekort  路  3Comments

ReneWeCode picture ReneWeCode  路  3Comments