Hi,

I'm digging through the simplenews.module file, and I can't find where to remove the "Newsletter Type" from the subject line. I only want the node title to appear. So, I'd like to remove everything in brackets, including the brackets themselves.

I've tried a few things.
Any help is appreciated.

kyle

Comments

sutharsan’s picture

Status: Active » Fixed

You can override the theme function responsible for theming the node body and title output.

kyle.vh’s picture

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

Change above to this:

function theme_simplenews_newsletter($node, $tid) {
$term = taxonomy_get_term($tid);
$node->subject = $node->title;
$node->body = ''. $node->title ."\n". $node->body;
return $node;
}
*(the < h > code gets stripped out when I post this, so the third line of code is messed up, but I didn't change it).
Right? Is that what you're suggesting? When I try this, the subject of the email is still: "[tax term name] Node title". I'm trying to yield: "Node title".
Thanks for any ideas.

kyle

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

Babalu’s picture

Status: Closed (fixed) » Active

subscribing

for D6 Version please

sutharsan’s picture

Status: Active » Closed (won't fix)
kevster’s picture

D6 - If you look around line 2414 of simplenews.module you will find:

return '['. $name .'] '. $title;

which you can then edit...

jwaxman’s picture

Sure would be nice to be able to set the title without having to hack the module.
Some sort of token scheme to allow the newsletter name and node title to be entered easily would be perfect.

miro_dietiker’s picture

As Sutharsan told:
For 5.x this is themeable - so don't hack the module but override the theming function.
For 6.x this is configurable. However 5.x is feature frozen so we won't backport this configurability.

freelylw’s picture

@miro_dietiker, 'For 6.x this is configurable'

My question is just where can I configure this in 6.x ? the bracket tile just looks unreasonable,nobody need this I guess.

n4te02’s picture

Instead of editing the module itself...In D6, just copy the function, place it in your template.php folder, and edit out the "'['. $name .']'" part.

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

Replace "theme" with your theme name and done!

tryitonce’s picture

...... thanks - very useful - might be good to make sure this is easily found in the documentation.

plan9’s picture

The Simple News template module also controls the subject line: http://drupal.org/project/simplenews_template

If you have this module installed you need to override the theme function: theme_simplenews_template_mail_subject()

You do not need to override or hack simplenews in this case.

maikeru’s picture

The problem with replacing the function in your template.php is the current problem with simplenews sending with the admin theme when using cron.

Even putting theme_simplenews_newsletter_subject into my admin themes template.php didn't work.

To get around this, I created a small module with the following in its sitehelper.module file:


/**
* Implementation of hook_theme_registry_alter().
*/
function sitehelper_theme_registry_alter(&$theme_registry) {
   if (!empty($theme_registry['simplenews_newsletter_subject'])) {
    $theme_registry['simplenews_newsletter_subject']['function'] = 'sitehelper_simplenews_newsletter_subject';
  }
}

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

brunox’s picture

This thread was very helpful in helping me to figure what was going on.. All i did was to ensure that the administration theme is the theme I'm working in(it was also the default theme) and the "Use administration theme for content editing" box is checked on the /admin/settings/admin page.. then I added the following in my template file.. worked like a charm..

mytheme_simplenews_newsletter_subject($name, $title, $language) {
  return  $name .'--'. $title;
}

PS version 6.x-1.3...

JCB’s picture

I can confirm #13 worked for me (using D6 Simplenews 6.x-1.4)

Here is my code used in my "custom" module.

function custom_theme_registry_alter(&$theme_registry) {
   if (!empty($theme_registry['simplenews_newsletter_subject'])) {
    $theme_registry['simplenews_newsletter_subject']['function'] = 'custom_simplenews_newsletter_subject';
  }
}

function custom_simplenews_newsletter_subject($name, $title, $language) {
	return $title . " - Site Name [www.website.co.za]";
}

Would it be possible to use global variables to use this as a dynamic solution for all my drupal sites?

By using Global site name and base path / website URL instead of having to hard-code it?

How would I go about doing this?