Commit dd53d4f2 authored by Bob Vincent's avatar Bob Vincent
Browse files

Autodetect template files.

parent 66b3105e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -51,11 +51,11 @@
<ol style="list-style-type: decimal;">
  <li>
    <h3>Template File</h3>
    <p>A template file is applied to your message header, subject, and body text. The default template is the included <code>htmlmail.tpl.php</code> file. You may copy this file to your default theme directory and use it to customize the contents and formatting of your messages. The comments within that file contain complete documentation on its usage.</p>
    <p>A template file is applied to your message header, subject, and body text. The default template is the included <code>htmlmail.tpl.php</code> file. You may copy this file to your <cite>email theme</cite> directory (selected below), and use it to customize the contents and formatting of your messages. The comments within that file contain complete documentation on its usage.</p>
  </li>
  <li>
    <h3>Theming</h3>
    <p><em>(Optional: requires <a href="http://drupal.org/project/echo">Echo</a> module.)</em> The templated text may be wrapped in a website theme. This lets you use any one of <a href="http://drupal.org/project/themes">over 800</a> themes to style your messages. Creating an email-specific sub-theme lets you use the full power of the <a href="http://drupal.org/documentation/theme">drupal theme system</a> to format your messages.</p>
    <p>You may choose a theme that will hold your templates from Step 1 above. If the <a href="http://drupal.org/project/echo">Echo</a> module.) is installed, this theme will also be used to wrap your templated text in a webpage. You use any one of <a href="http://drupal.org/project/themes">over 800</a> themes to style your messages, or <a href="http://drupal.org/documentation/theme">create your own</a> for even more power and flexibility.</p>
  </li>
  <li>
    <h3>Post-filtering</h3>
+10 −10
Original line number Diff line number Diff line
@@ -58,18 +58,18 @@ The email message text goes through three transformations before sending:
1.  <h3>Template File</h3>
    A template file is applied to your message header, subject, and body text.
    The default template is the included `htmlmail.tpl.php` file.  You may copy
    this file to your default theme directory and use it to customize the
    contents and formatting of your messages.  The comments within that file
    contain complete documentation on its usage.
    this file to your <cite>email theme</cite> directory (selected below), and
    use it to customize the contents and formatting of your messages. The
    comments within that file contain complete documentation on its usage.

2.  <h3>Theming</h3>
    *(Optional: requires [Echo](http://drupal.org/project/echo) module.)*
    The templated text may be wrapped in a website theme.  This lets you
    use any one of [over 800](http://drupal.org/project/themes) themes to
    style your messages.  Creating an email-specific sub-theme lets you use
    the full power of the
    [drupal theme system](http://drupal.org/documentation/theme)
    to format your messages.

    You may choose a theme that will hold your templates from Step 1 above. If
    the [Echo](http://drupal.org/project/echo) module.) is installed, this theme
    will also be used to wrap your templated text in a webpage.  You use any one
    of [over 800](http://drupal.org/project/themes) themes to style your
    messages, or [create your own](http://drupal.org/documentation/theme) for
    even more power and flexibility.

3.  <h3>Post-filtering</h3>
    You may choose a <cite>text format</cite> to be used for filtering email
+9 −9
Original line number Diff line number Diff line
@@ -62,16 +62,16 @@
    1. Template File
       A template file is applied to your message header, subject, and
       body text. The default template is the included htmlmail.tpl.php
       file. You may copy this file to your default theme directory and
       use it to customize the contents and formatting of your messages.
       The comments within that file contain complete documentation on its
       usage.
       file. You may copy this file to your email theme directory
       (selected below), and use it to customize the contents and
       formatting of your messages. The comments within that file contain
       complete documentation on its usage.
    2. Theming
       (Optional: requires [18]Echo module.) The templated text may be
       wrapped in a website theme. This lets you use any one of [19]over
       800 themes to style your messages. Creating an email-specific
       sub-theme lets you use the full power of the [20]drupal theme
       system to format your messages.
       You may choose a theme that will hold your templates from Step 1
       above. If the [18]Echo module.) is installed, this theme will also
       be used to wrap your templated text in a webpage. You use any one
       of [19]over 800 themes to style your messages, or [20]create your
       own for even more power and flexibility.
    3. Post-filtering
       You may choose a text format to be used for filtering email
       messages after theming. This allows you to use any combination of
+21 −27
Original line number Diff line number Diff line
@@ -38,13 +38,13 @@ function htmlmail_admin_settings() {
    '#type' => 'item',
    '#suffix' => t(
      // Begin instructions.
'<p>When formatting an email message, Drupal determines the active template directory by looking for <code>htmlmail.tpl.php</code> file in the following locations:</p>
<ul>
  <li><a href="http://api.drupal.org/api/drupal/includes--theme.inc/function/path_to_theme/7"><code>path_to_theme()</code></a></li>
  <li><a href="http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_get_path/7"><code>drupal_get_path</code></a><code>("module",</code><a href="http://api.drupal.org/api/drupal/developer--globals.php/global/installed_profile/7"><code>$installed_profile</code></a><code>)</code></li>
  <li><a href="http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_get_path/7"><code>drupal_get_path</code></a><code>("module",</code><a href="http://drupal.org/project/htmlmail"><code>"htmlmail"</code></a><code>)</code></li>
</ul>
<p>Once the active template directory is found, Drupal looks in that directory for template files in order from most specific to most general.</p>
'<p>When formatting an email message with a given <code>$module</code> and <code>$key</code>, <a href="http://drupal.org/project/htmlmail">HTML Mail</a> will use the first template file it finds from the following list:</p>
<ol style="list-style-type: decimal;">
  <li><code>htmlmail--$module--$key.tpl.php</code></li>
  <li><code>htmlmail--$module.tpl.php</code></li>
  <li><code>htmlmail.tpl.php</code></li>
</ol>
<p>For each filename, <a href="http://drupal.org/project/htmlmail">HTML Mail</a> looks first in the chosen <em>Email theme</em> directory, then in its own module directory, before proceeding to the next filename.</p>
<p>For example, if <code>example_module</code> sends mail with:</p>
<pre>
<code>drupal_mail("example_module", "outgoing_message" ...)
@@ -56,14 +56,9 @@ function htmlmail_admin_settings() {
  <li><code>htmlmail--example_module.tpl.php</code></li>
  <li><code>htmlmail.tpl.php</code></li>
</ul>
<p>The <code>$theme_hook_suggestions</code> variable contains an array of suggested <a href="http://api.drupal.org/api/drupal/includes--theme.inc/function/theme/7">theme</a> <a href="http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_theme/7">hooks</a>, in reverse priority order. For the above example, it would contain:</p>
<ul>
  <li><code>htmlmail__example_module</code></li>
  <li><code>htmlmail__example_module__outgoing_message</code></li>
</ul>
<p>For another example, to customize the <a href="http://api.drupal.org/api/drupal/modules--user--user.pages.inc/function/user_pass_submit/7">password reset</a> messages sent by the <a href="http://api.drupal.org/api/drupal/modules--user--user.module/7">user module</a>, copy <code>htmlmail.tpl.php</code> to your theme directory, and also copy it to <code>htmlmail--user_password_reset.tpl.php</code>, then modify the latter file. Remember that you will need to put <em>both</em> files in your theme directory for this to work.</p>
<p>Template files are cached, so remember to clear the cache by visiting <u>admin/config/development/performance</u> after creating, copying, or editing any <code>.tpl.php</code> files.</p>
<p>The following variables are also available in this template:</p>
<p>For another example, to customize the <a href="http://api.drupal.org/api/drupal/modules--user--user.pages.inc/function/user_pass_submit/7">password reset</a> messages sent by the <a href="http://api.drupal.org/api/drupal/modules--user--user.module/7">user module</a>, copy <a href="http://drupalcode.org/project/htmlmail.git/blob/refs/heads/7.x-2.x:/htmlmail.tpl.php"><code>htmlmail.tpl.php</code></a> to a file called <code>htmlmail--user--password_reset.tpl.php</code> in your <em>Email theme</em> directory, and edit the copy.</p>
<p>Template files are cached, so remember to clear the cache by visiting <u>admin/config/development/performance</u> after changing any <code>.tpl.php</code> files.</p>
<p>The following variables available in this template:</p>
<dl>
  <dt><strong><code>$body</code></strong></dt>
  <dd>
@@ -120,25 +115,24 @@ function htmlmail_admin_settings() {
  );
  $form['Step 2']['htmlmail_theme'] = array(
    '#type' => 'select',
    '#title' => t('Theming'),
    '#title' => t('Email theme'),
    '#default_value' => variable_get('htmlmail_theme', ''),
    '#options' => htmlmail_get_allowed_themes(),
    '#disabled' => !module_exists('echo'),
    '#prefix' => module_exists('echo') ? '': '<em>' . t(
      'Disabled: requires the <a href="!echo">Echo</a> module.',
      array('!echo' => url('http://drupal.org/project/echo'))
    ) . '</em>',
    '#suffix' => t(
      'The templated text may be wrapped in a website theme.  This lets you '
    '#suffix' => '<p>' . t(
      'Choose the theme that will hold your customized templates from Step '
      . '1 above.'
    ) . '</p><p>'
    . t( module_exists('echo') ?
      'The templated text will be styled by your chosen theme.  This lets you '
      . 'use any one of <a href="!themes">over 800</a> themes to style your '
      . 'messages.  Creating an email-specific sub-theme lets you use the full '
      . 'power of the <a href="!theme_system">drupal theme system</a> to '
      . 'format your messages.',
      . 'messages.  Creating an email-specific sub-theme lets you use the '
      . 'full power of the <a href="!theme_system">drupal theme system</a> '
      . 'to format your messages.' : '',
      array(
        '!themes' => 'http://drupal.org/project/themes',
        '!theme_system' => 'http://drupal.org/documentation/theme',
      )
    ),
    ) . '</p>',
  );
  $form['Step 3'] = array(
    '#type' => 'fieldset',
+17 −22
Original line number Diff line number Diff line
When formatting an email message, Drupal determines the active template
directory by looking for `htmlmail.tpl.php` file in the following locations:
When formatting an email message with a given `$module` and `$key`,
[HTML Mail](http://drupal.org/project/htmlmail)
will use the first template file it finds from the following list:

*    [`path_to_theme()`](http://api.drupal.org/api/drupal/includes--theme.inc/function/path_to_theme/7)
*    [`drupal_get_path`](http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_get_path/7)`("module", `[`$installed_profile`](http://api.drupal.org/api/drupal/developer--globals.php/global/installed_profile/7)`)`
*    [`drupal_get_path`](http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_get_path/7)`("module", `[`"htmlmail"`](http://drupal.org/project/htmlmail)`)`
1. `htmlmail--$module--$key.tpl.php`
2. `htmlmail--$module.tpl.php`
3. `htmlmail.tpl.php`

Once the active template directory is found, Drupal looks in that directory
for template files in order from most specific to most general.
For each filename,
[HTML Mail](http://drupal.org/project/htmlmail)
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:

@@ -18,29 +21,21 @@ the possible template file names would be:
*    `htmlmail--example_module.tpl.php`
*    `htmlmail.tpl.php`

The `$theme_hook_suggestions` variable contains an array of suggested
[theme](http://api.drupal.org/api/drupal/includes--theme.inc/function/theme/7)
[hooks](http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_theme/7),
in reverse priority order.  For the above example, it would contain:

*    `htmlmail__example_module`
*    `htmlmail__example_module__outgoing_message`

For another example, to customize the
[password reset](http://api.drupal.org/api/drupal/modules--user--user.pages.inc/function/user_pass_submit/7)
messages sent by the
[user module](http://api.drupal.org/api/drupal/modules--user--user.module/7),
copy `htmlmail.tpl.php` to your theme directory, and also
copy it to
`htmlmail--user_password_reset.tpl.php`,
then modify the latter file. Remember that you will need to put *both* files in
your theme directory for this to work.
copy
[`htmlmail.tpl.php`](http://drupalcode.org/project/htmlmail.git/blob/refs/heads/7.x-2.x:/htmlmail.tpl.php)
to a file called
`htmlmail--user--password_reset.tpl.php`
in your *Email theme* directory, and edit the copy.

Template files are cached, so remember to clear the cache by visiting
<u>admin/config/development/performance</u>
after creating, copying, or editing any `.tpl.php` files.
after changing any `.tpl.php` files.

The following variables are also available in this template:
The following variables available in this template:

**`$body`**
:   The message body text.
Loading