Here's some edits to the simplenews.module that allows you to wrap your HTML newsletter in a customisable template.

The template is ignored when sending in plain HTML format.

Edit 1

Add these in after Line number 883 which is $node = node_prepare($node); in th emodule version i'm using (4.7.5)

if ($node->s_format != 'plain') {
    $html_header =  variable_get('simplenews_header', '');
    $html_footer =  variable_get('simplenews_footer', '');
  }
  $node->body = ''.$html_header.''.$node->title.'</h2>'."\n".$node->body.''.$html_footer.'';
 

Edit 2

add this after line 1090

$form['sn_template'] = array(
      '#type' => 'fieldset',
      '#title' => t('HTML Newsletter template'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#description' => t('Customise your HTML emails by pasting in a header and footer. These settings are ignored when sending PLAIN text emails'),
    );
    $form['sn_template']['simplenews_header'] = array(
      '#type' => 'textarea', 
      '#title' => t('HTML Newsletter template header'), 
      '#default_value' => variable_get('simplenews_header', '<html><body>'), 
      '#cols' => 60, 
      '#rows' => 10, 
      '#description' => t('Paste your HTML Template Header')
    );
    
    $form['sn_template']['simplenews_footer'] = array(
      '#type' => 'textarea', 
      '#title' => t('HTML Newsletter template footer'), 
      '#default_value' => variable_get('simplenews_footer', '</body></html>'), 
      '#cols' => 60, 
      '#rows' => 10, 
      '#description' => t('Paste your HTML Template footer')
      );

Edit 3

Add this line at 1821. Just before valid_email_address() allows empty address, so check this first

      variable_set('simplenews_header', $edit['simplenews_header']);
      variable_set('simplenews_footer', $edit['simplenews_footer']);

Those edits will add a new option on the simplenews settings page allowing you to paste your html header and footer into a text area.

I was working on a project earlier today that required that and thought I would paste it up here. the simplenews.module - when sending emails, ignores any node-simplenews.tpl.php that you have setup. It stumped me for ages, so when I realised that was the case I set about adding the above.

hope that helps others...I didn't have time to create a patch..sorry. Maybe someone willimprove on the above and create a patch.

Dub

Comments

Dublin Drupaller’s picture

Sorry. Just noticed a type in the first edit..it should be this:

Edit 1.
Add this snippet in after line 883 which is $node = node_prepare($node); in the version I'm using.

if ($node->s_format != 'plain') {
    $html_header =  variable_get('simplenews_header', '');
    $html_footer =  variable_get('simplenews_footer', '');
  }
  $node->body = ''.$html_header.'<h2>'.$node->title.'</h2>'."\n".$node->body.''.$html_footer.'';
  

Dub

sutharsan’s picture

Version: 4.7.x-2.x-dev » 7.x-1.x-dev

Version changed to HEAD. The 4.7.x-2.x-dev branch is now no longer maintained.

enboig’s picture

Version: 7.x-1.x-dev » 5.x-1.1

does it work for 5.x-1.1? do I need to patch (and where) or it works automatically?

thanks

sutharsan’s picture

Status: Active » Closed (won't fix)

Option one: http://drupal.org/project/simplenews_template
Option two: custom theming with Contemplate module. See this handbook page: http://drupal.org/node/268404