I am trying to set simplenews in such a way, that would allow me to send only node teasers with read more links. I have copied simplenews-newsletter-body.tpl.php from the module's directory to my theme and trying to output:

 print '$node->readmore'.$node->readmore;
 print '$node->teaser'.$node->teaser;
 print '$teaser'.$teaser;
 print '$node->url'.$node->url;

Unfortunately, all variables are empty except $node->readmore, which gives not url, but digit: 1

How should I template simplnews to send only node teasers with read more links?

Comments

yngens’s picture

Overwriting a theme does not help also. For some reason

function blog_template_preprocess_simplenews_newsletter_body(&$variables) {
$variables['title'] = check_plain($variables['node']->title); 
$variables['test'] = "TEST TO SEE THIS IS MAKING IT TO TEMPLATE"; 
$variables['body'] = $variables['node']->body;
$variables['teaser'] = $variables['node']->teaser;
}

outputs empty teaser. And of course I cleared cache. Teaser is simply not available.

Myles McNally’s picture

I am today trying to do exactly what you want to do.

The reason the teaser is unavailable is line 1598 of simplenews.module.

unset($node->teaser);

Commenting out this line makes the teaser available. The surrounding code is about creating the body of the email message - being new to Drupal customization I am not sure what is going on here - I am sure it is doing something important (but what?). I have no idea why the value of the readmore variable comes back as 1.

The question is - why is the teaser unset, and could the $node variable simply be created with the teaser instead of the full content? My initial attempts break things.

yngens’s picture

Yes, it is always good to find out the reason why certain code was done the way it's done. Besides, I really hope there is a workaround without modifying the code in the module file.

Jane_dev’s picture

Trying to do something similar here... very surprised as to how little information there is about customizing the content of simplenews newsletters.

simon georges’s picture

Available variables are clearly stated in the template, as they are in other modules. Customising it means you know what you are doing.
If the body of the node is present, the teaser isn't, as it is often the case in Drupal. You may eventually generate it from the body (using node_teaser() function).

codevoice’s picture

I need a bump on this. Was this resolved by any of your first posters?

estebant’s picture

Go to the Content type configuration.

In Manage display (having CCK installed), click on Custom display settings, select "Email: HTML".
Now you can configure the fields separatedly from the other displays.

I use mimemail module, I am not sure if you need it to get the "Email: HTML" option.

miro_dietiker’s picture

Issue summary: View changes
Status: Active » Fixed

Question was answered.

Status: Fixed » Closed (fixed)

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