Some modules use ambiguous key names like "test" or "node". Therefore we use mimemail-message--node.tpl.

We will use this naming convention, but I would feel better if the template allowed for us to use the following template:
mimemail-message--simplenews--node.tpl.

Comments

sgabe’s picture

Status: Active » Needs review
StatusFileSize
new3.47 KB

We could use $message['id'] (which is $module . '_' . $key), instead of $message['key']. Please try the attached patch and report back.

sgabe’s picture

StatusFileSize
new4.41 KB

Please ignore the previous patch.

jjchinquist’s picture

Status: Needs review » Needs work

Hello sgabe,

The $variables['id'] cannot be used, as that is set by Drupal core. Can we use "mail_id" or "mail_key"?
I just attempted to reproduce the patch using "mail_id" instead of "id", and when I print the variable in the mimemail-message.tpl.php, I get an empty string.

If I can get to it before, then I will submit a revised patch.

Regards,
Jeremy

djg_tram’s picture

Sorry, I really don't have time to roll this into a real patch now but this can be solved in a simpler and nicer way, here it is how.

mimemail.module

* in mimemail_prepare_message():

  $module = $message['module'];
  $key = $message['key'];

* same function, near the end:

  $hook = array(
    'mimemail_message__' . $module .'__'. $key,
    'mimemail_message__' . $key,
    'mimemail_message__' . $module,
    'mimemail_message',
  );
  $variables = array('module' => $module, 'key' => $key, 'recipient' => $to, 'subject' => $subject, 'body' => $body);
  $body = theme($hook, $variables);

mimemail.theme.inc

* in mimemail_theme_theme():

  return array(
    'mimemail_message' => array(
      'variables' => array('module' => NULL, 'key' => NULL, 'recipient' => NULL, 'subject' => NULL, 'body' => NULL),
      'template' => 'mimemail-message',
      ...

* end of template_preprocess_mimemail_message():

  $variables['module'] = str_replace('_', '-', $variables['module']);
  $variables['key'] = str_replace('_', '-', $variables['key']);

Thanks if you can include it somehow.

sgabe’s picture

Title: Change template naming logic. Use module as well » Change template naming logic to use module as well
Status: Needs work » Fixed
StatusFileSize
new4.75 KB

The attached patch has been committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.