I really like this module!

Is there a way to get rid of the annoying title text from the body of the email when it's sent?

As a side question, is there any way that a user can customize the subject line without the "[Newsletter Name] Title" format? Thanks!

Comments

sutharsan’s picture

Status: Active » Fixed

Yes, subject, title, message body and more can be customized by theming.
Override the Simplenews theme functions as described in the handbook: http://drupal.org/node/55126
You need to override the theme_simplenews_newsletter() function.

Ray Seaman’s picture

Thanks for your quick reply, Sutharsan.

I'm no coder, so is there a code snippet that you could point me to that all I'll need to do is copy and paste?

I would like the title to be my subject, but not have the title text appear in the body of my email - that's all.

Thanks again!

Ray Seaman’s picture

Status: Fixed » Postponed (maintainer needs more info)
sutharsan’s picture

It is actually quite simple once you know the trick:

(assuming you have a theme based on phpTemplate engine)
1. Find the function I mentioned in #1
2. Copy this modified function into the template.php file
3. Change the "theme_" part of the function name into "phptemplate_"
4. Start messing with the content of the function until you have the result you want.

At step 3 you have this code:

function phptemplate_simplenews_newsletter($node, $tid) {
  $term = taxonomy_get_term($tid);
  $node->subject = '['. $term->name .'] '. $node->title;
  $node->body = '<h2>'. $node->title ."</h2>\n". $node->body;
  return $node;
}

Learn this trick, read the manual, get practice and you will be a theming master ;)

roald’s picture

Hi!

I had the same wish (also since the strtoupper function used does not handle accented characters very well), so I edited line 2304 in simplenews.module from

$node->body = '<h2>'. $node->title ."</h2>\n". $node->body;
to
$node->body = $node->body;

Easy and dirty, but worked ;-)

Roald

Ray Seaman’s picture

Thanks!

It works, but there's still a large gap between the top of the email and the beginning of the message, which is rather unsightly from a design perspective.

I'll of course be looking into Sutharsan's method as well when I get some time.

Thanks again!

sutharsan’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

You may have a look at simplenews_template module. This give more control over the newsletter theming.
Feel free to re-open the issue if you need more support.

Ray Seaman’s picture

Thanks! I actually did get SimpleNews to do what I wanted to do by using the theme override stuff you mentioned earlier. Thanks again!

gmclelland’s picture

Component: Miscellaneous » Code
function phptemplate_simplenews_newsletter($node, $tid) {
  $term = taxonomy_get_term($tid);
  $node->subject = '['. $term->name .'] '. $node->title;
  $node->body = '<h2>'. $node->title ."</h2>\n". $node->body;
  return $node;
}

When I try to add the code snippet(Sutharsan's) above to my template.php, it results with this error.

Fatal error: Cannot redeclare phptemplate_simplenews_newsletter() (previously declared in C:\WEBSITES\Drupal_Projects\drupalsandbox\sites\all\modules\simplenews_template\simplenews_template.module:108) in C:\WEBSITES\Drupal_Projects\drupalsandbox\sites\all\themes\custom\template.php on line 100

Any ideas on how to fix this?

Thanks

gmclelland’s picture

I think this is causing an error because simplenews_template.module is overriding the simplenews.module theme function. Now how would I override simplenews_template.module function in my template.php?

I don't want hack the simplenews_template.module.

Thanks

gmclelland’s picture

Ok, it looks like I just had to override these functions.

function phptemplate_simplenews_template_content()
function phptemplate_simplenews_template_mail_subject()

drupal@guusvandewal.nl’s picture

I've succesfully removed the title of the newsletter by editing the template.php like this (Drupal6) :

function MYTHEMENAME_preprocess_simplenews_newsletter_body(&$variables) {
  $variables['title'] = "";
  $variables['body'] = $variables['node']->body;
}

For changing the email subject edit template.php:

function MYTHEMENAME_simplenews_newsletter_subject($name, $title, $language) {
 return  $title;
}

Hope this helps others, thanks for pointing me in the right direction.

G