Download & Extend

changing the content of what is in the digest

Project:Simplenews Digest
Version:6.x-1.x-dev
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

From the description, it looks like it will only send out the title of each node....can the teaser be sent out as well? entire node? I also use the attached image for the node type I have set to send out in the newsletter and would like that to be included too.

Comments

#1

Not currently, no. Feel free to submit a patch.

#2

Category:support request» feature request

I would if I could....but I'm no coder! :)

I'd probably be able to find where in the code its set to say "send the title" but I'd have no idea what to change it to send the teaser. I'm sure I'd mess it up.

I'm more than willing and able to test it tho! :)

#3

We'll probably make this an improvement at some point but I can't promise on when I can deliver. Could be a couple of months at least.

#4

sure thing. understandable. I left it as a feature request....maybe someone else out there can help.

Even if it doesn't get into a proper UI, at least a bit of code to change out would be amazing. I did see in the .module where the content is set....all of 3 or 4 lines heh?! Amazing.

#5

I recently got startet with Simplenews and Simplenews Digest (SD) on D6, and I was facing the same challenge. By looking at the code I noticed, that SD uses a theme function to actually generate the content of the newsletter. It passes the nodes with their id, title and url to the function and then renders the content.

So what I do is I override the theme function with a template called "simplenews_digest_format_newsletter.tpl.php", where I copied the code from the function "theme_simplenews_digest_format_newsletter()". If you do that, don't forget to print $output or you won't see anything. When SD now loops through the nodes in my template, I simply load the node by its id and then have all the fields I need.

What I do not understand yet: the override of the theme function with a template file only works, when calling SD via cron.php. When I - for testing purposes - call it via _simplenews_digest_cron_routine() from a module, SD always defaults to the theme function of the module.

I still have to investigate though if I need the template file also in my main theme directory, because I am actually using a subtheme of Zen.

#6

+1 for the feature request of choosing between title only, teaser or body.

#7

+1 for the feature, perhaps to be set via content type -> display fields -> Simplenews Digest

#8

There will be better support for theming in the new version of the module.

#9

Status:active» needs work

#10

#5 works for me.
I'm sorry, I don't know how to make a patch.

In the file simplenews_digest.module

FIND :

<?php
// Drupal Hook_theme

function simplenews_digest_theme() {

  return array(

   
'simplenews_digest_format_newsletter' => array(

     
'arguments' => array('newsletter' => array()),

    ),

  );

}
?>

REPLACE BY

<?php
// Drupal Hook_theme

function simplenews_digest_theme() {

  return array(

   
'simplenews_digest_format_newsletter' => array(

     
'template' => 'simplenews-digest-format-newsletter',
     
'arguments' => array('newsletter' => array(), 'content_types' => array()),

    ),

  );

}
?>

FIND

<?php
  $newsletter
['new_nodes'] = simplenews_digest_select_nodes($newsletter);

 
$newsletter['body'] = theme('simplenews_digest_format_newsletter', $newsletter);
?>

REPLACE BY
<?php
  $newsletter
['new_nodes'] = simplenews_digest_select_nodes($newsletter);

 
$content_types = variable_get('simplenews_digest_content_types', 0);
 
$newsletter['body'] = theme('simplenews_digest_format_newsletter', $newsletter, $content_types);
?>

FIND

<?php
// Generate the body of the newsletter

function theme_simplenews_digest_format_newsletter(&$newsletter) {

 
// Get sections of newsletter, each section is a listing of links to nodes sorted by content type/date

 
$content_types = variable_get('simplenews_digest_content_types', 0);

[...]
 
$output = theme('simplenews', $content_types);   
  return
$output;
}
?>

REPLACE BY

<?php
// Generate the body of the newsletter
/*
function theme_simplenews_digest_format_newsletter(&$newsletter) {

  // Get sections of newsletter, each section is a listing of links to nodes sorted by content type/date

  $content_types = variable_get('simplenews_digest_content_types', 0);

[...]
  $output = theme('simplenews', $content_types);   
  return $output;
}*/
?>

Now, create this file : simplenews-digest-format-newsletter.tpl.php

<?php
   
// Get sections of newsletter, each section is a listing of links to nodes sorted by content type/date
    //$content_types = variable_get('simplenews_digest_content_types', 0);
   
$output_by_type = array();
    if (
$content_types) {
       
$selected_content_types = array_filter($content_types);
        foreach (
$newsletter['new_nodes'] as $node) {
            foreach(
$selected_content_types as $type) {
                if(
$node->type == $type) {
               
$output_by_type[$type] .= simplenews_digest_create_node_link($node) . "\n\n";
                }
            }
        }
    }

   
// Nothing to send, no newsletter is sent
   
if (!$output_by_type) {
        return
'';
    }

   
// $newsletter['body'] created here
   
$output = '';
   
// Sort content by type
   
foreach($output_by_type as $type => $content) {
       
$new_name = check_plain(variable_get('simplenews_digest_content_rename_' . $type, node_get_types('name', $type)));
       
$output .= "<h1>$new_name</h1>" . $content . "\n";
    }

  echo
$output;
?>

#11

As described here http://drupal.org/node/11811 you only need to override the theme function theme_simplenews_digest_format_newsletter(&$newsletter) by your own theme function inside template.php with phptemplate_simplenews_digest_format_newsletter($newsletter). This also fixes the bug related to the wrong reference handling of the original theme function what completely prevents sending the newsletter mail.

nobody click here