0

In Craft CMS 5, is there a way to customize the content of system messages outside of the Control Panel (under /admin/utilities/system-messages)?

I’m working on a multi-language site and would like to avoid having to update message content directly in the database.

I attempted to create the following templates:

  • /templates/email/password-reset.twig
  • /templates/email/account-activation.twig
  • /templates/email/email-verification.twig

However, Craft still seems to be pulling the content from the database rather than these template files.

Is there a way to override the system messages to use these templates instead? Any guidance would be greatly appreciated.

2 Answers 2

0

I found the solution in the supplementary documentation here:
Supergeekery - CraftCMS HTML Email Template Missing Documentation

In Craft CMS 5, you can indeed override the default system messages without modifying them directly in the Control Panel or database. Instead of relying on the content from /admin/utilities/system-messages, you can customize the email templates by switching based on the email type (emailKey).

To do this, add the following switch block to your email template:

{% switch emailKey %} {% case "account_activation" %} <p>{{ "You're activating your email." | t }}</p> {% case "verify_new_email" %} <p>{{ "Let's verify your new email address." | t }}</p> {% case "forgot_password" %} <p>{{ "Don't worry, we'll reset that password now." | t }}</p> {% case "test_email" %} <p>{{ "Testing makes perfect." | t }}</p> {% default %} {{ body }} {% endswitch %} {{ body }} 

However, instead of hardcoding the text like this, you can include the templates you've already created in your /templates/email/ folder:

{% switch emailKey %} {% case "account_activation" %} {% include "email/account-activation.twig" %} {% case "verify_new_email" %} {% include "email/email-verification.twig" %} {% case "forgot_password" %} {% include "email/password-reset.twig" %} {% case "test_email" %} {% include "email/test-email.twig" %} {% default %} {{ body}} {% endswitch %} {{ body }} 

This approach allows you to fully customize the content of system messages outside of the database by utilizing template files, and it also supports multi-language setups.

-1

You could create your own fields (as Globals) and refer to them in your templates.

This way (after setting the Translation Method for each field) you get translations out of the box and can set different messages for each site.

1
  • The issue here is that Craft is still fetching the encoded content from /admin/utilities/system-messages (i.e., from the database) instead of retrieving the custom templates. Commented Aug 28, 2024 at 14:45

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.