--- simplenews_template 2/simplenews_template.module 2008-12-05 05:41:22.000000000 -0800 +++ simplenews_template/simplenews_template.module 2009-01-12 11:27:16.000000000 -0800 @@ -13,7 +13,7 @@ * * Sponsors: * Spoon Media - * Webbredaktören + * Webbredakțren */ @@ -32,10 +32,16 @@ function simplenews_template_perm() { * Implementation of hook_mail_alter. */ function simplenews_template_mail_alter(&$message) { + static $processed; + $function = "_simplenews_template_mail_alter_{$message['id']}"; if (function_exists($function)) { $function($message); } + else if (!$processed) { + _simplenews_template_mail_alter_simplenews_node($message); + $processed = TRUE; + } } /** @@ -82,9 +88,16 @@ function simplenews_template_form_alter( /** * Apply template to a newsletter as its sent. */ -function _simplenews_template_mail_alter_simplenews_node(&$message) { +function _simplenews_template_mail_alter_simplenews_node(&$message) { // Setup newsletter data - $tid = reset($message['params']['context']['account']->tids); + + if (!empty($message['params']['context']['account']->tids)) { + $tid = reset($message['params']['context']['account']->tids); + } + else { + $tid = $message['params']['context']['newsletter']->tid; + } + $newsletter = taxonomy_get_term($tid); $node = $message['params']['context']['node']; $content = $message['body']['body']; @@ -367,8 +380,8 @@ function simplenews_template_theme_regis /** * Hi-jacker to stop the title from being inserted above the HTML in the mail. */ -function _simplenews_template_theme_simplenews_newsletter_body($body, $title, $language) { - return $body; +function _simplenews_template_theme_simplenews_newsletter_body($node, $language) { + return drupal_render($node->content); } /**