htmlmail.html.twig in HTML Mail 8
Same filename and directory in other branches
Default template for HTML Mail.
DO NOT EDIT THIS FILE. Copy it to your theme directory, and edit the copy.
========================================================= Begin instructions.
When formatting an email message with a given $module and $key, [1]HTML Mail will use the first template file it finds from the following list: 1. htmlmail--$module--$key.html.twig 2. htmlmail--$module.html.twig 3. htmlmail.html.twig
For each filename, [2]HTML Mail looks first in the chosen Email theme directory, then in its own module directory, before proceeding to the next filename.
For example, if example_module sends mail with: drupal_mail("example_module", "outgoing_message" ...)
the possible template file names would be: 1. htmlmail--example_module--outgoing_message.html.twig 2. htmlmail--example_module.html.twig 3. htmlmail.html.twig
Template files are cached, so remember to clear the cache by visiting admin/config/development/performance after changing any .html.twig files.
The following variables available in this template:
message.body The message body text.
message.module The first argument to [3]drupal_mail(), which is, by convention, the machine-readable name of the sending module.
message.key The second argument to [4]drupal_mail(), which should give some indication of why this email is being sent.
message.message_id The email message id, which should be equal to "{$module}_{$key}".
message.headers An array of email (name => value) pairs.
message.from The configured sender address.
message.to The recipient email address.
message.subject The message subject line.
message.body The formatted message body.
message.language The language code for this message.
message.params Any module-specific parameters.
template_name The basename of the active template.
template_path The relative path to the template directory.
template_url The absolute URL to the template directory.
theme The name of the Email theme used to hold template files. If the [5]Echo module is enabled this theme will also be used to transform the message body into a fully-themed webpage.
theme_path The relative path to the selected Email theme directory.
theme_url The absolute URL to the selected Email theme directory.
debug TRUE to add some useful debugging info to the bottom of the message.
Other modules may also add or modify theme variables by implementing a MODULENAME_preprocess_htmlmail(&$variables) [6]hook function.
References
1. http://drupal.org/project/htmlmail 2. https://www.drupal.org/documentation/theme 3. https://www.drupal.org/developing/api/8/render 4. http://drupal.org/project/echo
=========================================================== End instructions.
File
templates/htmlmail.html.twigView source
- {#
- /**
- * @file
- * Default template for HTML Mail.
- *
- * DO NOT EDIT THIS FILE. Copy it to your theme directory, and edit the copy.
- *
- * ========================================================= Begin instructions.
- *
- * When formatting an email message with a given $module and $key, [1]HTML
- * Mail will use the first template file it finds from the following list:
- * 1. htmlmail--$module--$key.html.twig
- * 2. htmlmail--$module.html.twig
- * 3. htmlmail.html.twig
- *
- * For each filename, [2]HTML Mail looks first in the chosen Email theme
- * directory, then in its own module directory, before proceeding to the
- * next filename.
- *
- * For example, if example_module sends mail with:
- * drupal_mail("example_module", "outgoing_message" ...)
- *
- *
- * the possible template file names would be:
- * 1. htmlmail--example_module--outgoing_message.html.twig
- * 2. htmlmail--example_module.html.twig
- * 3. htmlmail.html.twig
- *
- * Template files are cached, so remember to clear the cache by visiting
- * admin/config/development/performance after changing any .html.twig files.
- *
- * The following variables available in this template:
- *
- * message.body
- * The message body text.
- *
- * message.module
- * The first argument to [3]drupal_mail(), which is, by convention,
- * the machine-readable name of the sending module.
- *
- * message.key
- * The second argument to [4]drupal_mail(), which should give some
- * indication of why this email is being sent.
- *
- * message.message_id
- * The email message id, which should be equal to
- * "{$module}_{$key}".
- *
- * message.headers
- * An array of email (name => value) pairs.
- *
- * message.from
- * The configured sender address.
- *
- * message.to
- * The recipient email address.
- *
- * message.subject
- * The message subject line.
- *
- * message.body
- * The formatted message body.
- *
- * message.language
- * The language code for this message.
- *
- * message.params
- * Any module-specific parameters.
- *
- * template_name
- * The basename of the active template.
- *
- * template_path
- * The relative path to the template directory.
- *
- * template_url
- * The absolute URL to the template directory.
- *
- * theme
- * The name of the Email theme used to hold template files. If the
- * [5]Echo module is enabled this theme will also be used to
- * transform the message body into a fully-themed webpage.
- *
- * theme_path
- * The relative path to the selected Email theme directory.
- *
- * theme_url
- * The absolute URL to the selected Email theme directory.
- *
- * debug
- * TRUE to add some useful debugging info to the bottom of the
- * message.
- *
- * Other modules may also add or modify theme variables by implementing a
- * MODULENAME_preprocess_htmlmail(&$variables) [6]hook function.
- *
- * References
- *
- * 1. http://drupal.org/project/htmlmail
- * 2. https://www.drupal.org/documentation/theme
- * 3. https://www.drupal.org/developing/api/8/render
- * 4. http://drupal.org/project/echo
- *
- * =========================================================== End instructions.
- */
- #}
- <div class="htmlmail-body">
- {{ message.body }}
- </div>
-
- {% if debug %}
- <hr />
- <div class="htmlmail-debug">
- <dl>
- <dt>
- <p>To customize this message:</p>
- </dt>
- <dd>
- <ol>
- {% if not theme %}
- <li>
- <p>
- Visit <u>admin/config/system/htmlmail</u> and select a theme to hold your custom email template files.
- </p>
- </li>
- {% elseif not theme_path %}
- <li>
- <p>
- Visit <u>admin/appearance</u> to enable your selected <u>{{ theme|capitalize }}</u> theme.
- </p>
- </li>
- {% endif %}
-
- {% set themeTemplate = "%s/%s"|format(theme_path, message_template) %}
- {% if _self.getTemplateName() == themeTemplate %}
- <li>
- <p>
- Edit your<br />
- <code>
- {{ _self.getTemplateName() }}
- </code>
- <br />file.
- </p>
- </li>
- {% endif %}
- {% if not theme_html_exists %}
- <li>
- <p>
- Copy<br />
- <code>{{ module_path }}/htmlmail.html.twig</code>
- <br />to<br />
- <code>{{ theme_path }}/htmlmail.html.twig</code>
- </p>
- </li>
- {% endif %}
- {% if not module_template_exists %}
- <li>
- <p>
- For module-specific customization, copy<br />
- <code>{{ module_path }}/htmlmail.html.twig</code>
- <br />to<br />
- <code>{{ theme_path }}/{{ module_template }}</code>
- </p>
- </li>
- {% endif %}
- {% if not message_template_exists %}
- <li>
- <p>
- For message-specific customization, copy<br />
- <code>{{ module_path }}/htmlmail.html.twig</code>
- <br />to<br />
- <code>{{ theme_path }}/{{ message_template }}</code>
- </p>
- </li>
- {% endif %}
- <li>
- <p>
- Edit the copied file.
- </p>
- </li>
- <li>
- <p>
- Send a test message to make sure your customizations worked.
- </p>
- </li>
- <li>
- <p>
- If you think your customizations would be of use to others,
- please contribute your file as a feature request in the
- <a href="http://drupal.org/node/add/project-issue/htmlmail">issue queue</a>.
- </p>
- </li>
- </ol>
- </dd>
- {% if message.params %}
- <dt>
- <p>
- The {{ message.module }} module sets the <u><code>message.params</code></u>
- variable. For this message,
- </p>
- </dt>
- <dd>
- <p>
- <code>
- <pre>
- $params = {{ pre_formatted_params }}
- </pre>
- </code>
- </p>
- </dd>
- {% endif %}
- </dl>
- </div>
- {% endif %}