function htmlmail_admin_settings in HTML Mail 7
Same name and namespace in other branches
- 8.2 htmlmail.admin.inc \htmlmail_admin_settings()
- 5 htmlmail.module \htmlmail_admin_settings()
- 6.2 htmlmail.admin.inc \htmlmail_admin_settings()
- 6 htmlmail.admin.inc \htmlmail_admin_settings()
- 7.2 htmlmail.admin.inc \htmlmail_admin_settings()
Implements hook_admin_settings().
1 string reference to 'htmlmail_admin_settings'
- htmlmail_menu in ./
htmlmail.module - Implements hook_menu().
File
- ./
htmlmail.admin.inc, line 11 - Admin forms for HTML Mail
Code
function htmlmail_admin_settings() {
$formats = array(
'0' => 'Unfiltered',
);
foreach (filter_formats() as $id => $filter) {
$formats[$id] = $filter->name;
}
$form['htmlmail_prefilter'] = array(
'#type' => 'select',
'#title' => t('Text format pre-filter'),
'#default_value' => variable_get('htmlmail_prefilter'),
'#options' => $formats,
'#description' => t('Choose a <a href="/admin/config/content/formats">text format</a> to be used for filtering email messages <em>before</em> the selected theme or template is applied.'),
);
$form['htmlmail_template'] = array(
'#type' => 'fieldset',
'#title' => t('Template file documentation'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['htmlmail_template']['info'] = array(
'#markup' => t('<p>When formatting an email message, Drupal determines the active template directory by looking for <cite>htmlmail.tpl.php</cite> file in the following locations:</p>
<ul>
<li><a href="http://api.drupal.org/api/drupal/includes--theme.inc/function/path_to_theme/7">path_to_theme()</a></li>
<li><a href="http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_get_path/7">drupal_get_path(</a>"module", <a href="http://api.drupal.org/api/drupal/developer--globals.php/global/installed_profile/7">$installed_profile</a>)</li>
<li><a href="http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_get_path/7">drupal_get_path(</a>"module", <a href="http://drupal.org/project/htmlmail">"htmlmail"</a>)</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>For example, if <cite>foo_module</cite> sends mail with:</p>
<p><code>drupal_mail("foo_module", "outgoing_message" ...)</code></p>
<p>the possible template file names would be:</p>
<ul>
<li><code>htmlmail-foo_module_outgoing_message.tpl.php</code></li>
<li><code>htmlmail-foo_module_outgoing.tpl.php</code></li>
<li><code>htmlmail-foo_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</code></li>
<li><code>htmlmail-foo_module</code></li>
<li><code>htmlmail-foo_module_outgoing</code></li>
<li><code>htmlmail-foo_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> emails 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 <cite>admin/settings/performance</cite> after creating, copying, or editing any <code>.tpl.php</code> files.</p>
<p>The following variables are also available in this template:</p>
<p><code>$body</code> : The message body text.</p>
<p><code>$module</code> : The sending module name, usually the first parameter to drupal_mail().</p>
<p><code>$key</code> : The email message id.</p>
<p><code>$header</code> : The configured header text.</p>
<p><code>$footer</code> : The configured footer text.</p>
<p><code>$css</code> : The configured css style rules.</p>
<p><code>$debug</code> : TRUE if debugging info should be printed.</p>
<p><code>$directory</code> : The relative path to the theme template directory.</p>
<p><code>$theme_url</code> : The absolute URL to the theme directory.</p>
<p>The module calling <a href="http://api.drupal.org/api/drupal/includes--mail.inc/function/drupal_mail/7">drupal_mail()</a> may set other variables. For instance, the <a href="http://drupal.org/project/webform">Webform module</a> sets a <code>$node</code> variable which may be very useful.</p>
<p>Other modules may also add or modify theme variables by implementing a <code>MODULENAME_preprocess_htmlmail()</code> <a href="http://api.drupal.org/api/drupal/modules--system--theme.api.php/function/hook_preprocess_HOOK/7">hook function</a>.</p>'),
);
$form['htmlmail_theme'] = array(
'#type' => 'select',
'#title' => t('Theme to use for emails'),
'#default_value' => variable_get('htmlmail_theme', ''),
'#options' => htmlmail_get_allowed_themes(),
'#description' => t('You may use a template or a website theme to format your emails. See !readme for details.', array(
'!readme' => l('README.txt', drupal_get_path('module', 'htmlmail') . '/README.txt'),
)),
);
$form['htmlmail_postfilter'] = array(
'#type' => 'select',
'#title' => t('Text format post-filter'),
'#default_value' => variable_get('htmlmail_postfilter'),
'#options' => $formats,
'#description' => t('Choose a <a href="/admin/config/content/formats">text format</a> to be used for filtering email messages <em>after</em> the selected theme or template is applied.'),
);
$form['htmlmail_debug'] = array(
'#type' => 'checkbox',
'#title' => t('Debug'),
'#default_value' => variable_get('htmlmail_debug', '0'),
'#description' => t('Add module name to bottom of email. Useful for theme template suggestion or exclusion settings.'),
);
return system_settings_form($form);
}