I have followed the handbook to set up an html newsletter using tables. I can get all the static stuff in place. But for days I have tried to find a way to populate the body of the newsletter with stories, and have gotten no further than getting the headlines.

I added a nodereference field, field_nl_stories, that uses a view that filters on Published=yes, Type=blog entry, page, story, and Post Date < 45 days ago. Sort by Post Date, Display title, author, body. That gives me a select list in the node form. So far so good.

I then put into the node-simplenews-body.tpl.php a loop to go through the selected field_nl_stories entries. But the best result I have come up with is getting the headlines with

foreach ((array)$node->field_nl_stories as $item {
  print content_format(field_nl_stories, $item).'<br/>';
}

I cannot get the author or body fields to print, no matter what variation on this I try.

The other major problem with this method is I cannot control the order in which stories appear. They are, due to the view sort, presented by date descending. My alternative might be to set up a series of nodereference fields, i.e., field_nl_story1, field_nl_story2, ..., and then put them in a group. But until I find a way to print the author and body fields under the title that is just a dream.

Can anyone explain clearly for us non-pro site administrators how to do this. The current documentation assumes a level of knowledge above mine and, I suspect, many of us. It also is written mainly for D5.

Thanks

Comments

Status:Active» Closed (duplicate)

rsbecker,

Did you ever find a solution for this?

After a considerable amount of casting about and trying things I actually came up with a way to accomplish what I needed in terms of creating the email newsletter. I still am working on creating a node-simplenews-edit.tpl.php file for creating the newsletter.

A big part of the problem I had was solved when I realized I had to use node_load() to make the fields I needed available to simplenews. I did not see anything in the D5 explanation. It simply assumed I would know what cck fields I needed to create and how to use them to pull data using nodereference.

Another problem not addressed in the D5 version is that phptemplate_callback() does not work in D6, so it took a while to find a workaround for creating the online version and, by extension, the template to edit the newsletter.

Maybe I will feel moved when I finish this to document how I did it in D6, or maybe I'll be so frustrated I'll just buy a ticket to Tahiti.

Thanks for asking. Now that D7 is on the horizon I think documentation of using simplenews in D6 by us end users would be very helpful.

I have one last problem creating a node-simplenews-edit.tpl.php file. It's probably a simple one that themers do without thinking much about, but I have been searching for days.

I have a series of node reference fields, field_nl_story_0, field_nl_story_1, ... field_nl_story_9. Each is a select list populated by a view of potential newsletter stories. I chose to create 10 of these so I can easily place stories in the order I want them, rather than having to live with some sort, i.e. most recent, most popular, etc.

What I have not been able to do is place those fields in the template so they are in the positions they will occupy when the newsletter is completed. All appear below the area that looks like the final newsletter, with all of the other form fields. I have tried function theme_item($form['field_nl_story_0']) and or $node['field_nl_story_0']). I have tried several other ideas, but none seems to work.

How do I put the select lists where I want them???

Hi rsbecker, I have a similar issue that you had solved (above), only my level of knowledge is less developed. MY newsletter is nearly identical to yours (as my followed the same steps from an early Drupal Forum article) I made a newsletter html table template and when I save my newsletter I cna view it fine on my website. However, when I open up the same newsletter sent out to my email, only the title of the nodes appear, which are linked to the nodes themselves on my website.

So I'm thinking that I also have to use node_load, but I don't know the steps. Does anyone have any pointers?

Thanks!

Here are two sections of my simplenews-newsletter-body-....tpl.php file. There may be a more elegant way to do this, but I'm a total amateur.

$issue_date = $node->field_nl_issue_date[0]['view'];
$story1 = $node->field_nl_story_1[0]['nid'];
$story1 = node_load($story1);
if ($node->field_nl_story_2[0]['nid'] != '') {
  $story2 = $node->field_nl_story_2[0]['nid'];
  $story2 = node_load($story2);
}
if ($node->field_nl_story_3[0]['nid'] != '') {
  $story3 = $node->field_nl_story_3[0]['nid'];
  $story3 = node_load($story3);
}
...
?>
...
// TOC generated here.
  <tr>
      <td>
         <table width="620" align="center" cellspacing="0" cellpadding="10px">
            <tr>
               <td width="200" valign="top" style="border-right: 2px solid blue; text-aligh: center;"><div class="sidebar">
                  <h2>In this issue</h2>
                  <ul><?php
           
for ($i=1; $i<=12; $i++) {
             
$story = "story" . $i;
             
$story = $$story;
              if (
$story->title != '') {
                    print
"<li><a href='#story" . $i . "'>" . $story->title . "</a></li>";
              }
                    }
...
// Stories generated here, either as teasers with Read more links to the web version or as full length stories
               
</div></td>
                <
td width="400" align="center" valign="top"><div class="mainbar">
            <?
php
                   
if ($node->field_nl_teaserversion[0]['value'] == '1') {
                      for (
$i=1; $i<=12; $i++) {
                  
$story = "story" . $i;
                 
$story = $$story;
                       
$storyid = $story->nid;
                  if (
$story->title != '') {
                     print
"<a href='http://www.spjdc.org/node/" . $storyid . "' target='_blank' name='story".$i."'><h2>" . $story->title . "</h2></a>";
                          if (
strlen($story->teaser) < strlen($story->body)) {
                      print
$story->teaser;
                            print
"<a class='readmore' href='http://www.spjdc.org/node/" . $storyid . "' target='_blank'>... Read more.</a>";
                          }
                          else {
                      print
'<p>'.$story->teaser.'</p>';
                          }
                          print
'<a href="#top" class="center">Back to top^</a>';
                  }
                      }
                    }
                    else {
                      for (
$i=1; $i<=12; $i++) {
                  
$story = "story" . $i;
                 
$story = $$story;
                  if (
$story->title != '') {
                     print
"<a name='story" . $i . "'><h2>" . $story->title . "</h2></a>";
                    print
'<p>'.$story->body.'</p>';
                          print
'<a href="#top" class="center">Back to top^</a>';
                        }
                }
                    }
           
?>

...

This has been the most helpful post I have found on Simplenews! Thank you. I realized how much I didn't know about variables and node_load() before my first post.

I created a node reference view as suggested in the D5 handbook page and used it to populate select lists for each story field (field_nl_story_NO.), but I did not embed the view and did not modify any of the views tpl files. I arbitrarily chose Story as the node type to use for newsletter stories and set a filter to sho all stories in the past 45 days as candidates for the newsletter.

I did create a node-simplenews-edit.tpl.php file and a node-simplenews.tpl.php file to display the newsletter as a node on the site. If you go to www.spjdc.org and click the April 2010 link in the upper right you will see the node version.

I also had to create a print.node-simplenews.tpl.php file for the printer friendly version. All of the display tpl files are similar, but there are some quirks about how MimeMail handles html, so I had to vary the code and the embedded stylesheets a little in each to make the content display properly.

The node-simplenews-edit.tpl.php file has a series of php print statements, one for each field_nl_story_NO. That was necessary to place the stories in the order I wanted them to appear.

I was never able to get the template to show the bodies of stories as I select them. There are ways to do that using js or #ahah onclick statements, but that's above my knowledge level.

Someday I may sit down and write all of this out to replace the documentation on the Drupal site.

Hi, thank you rsbecker, with your help I got my newsletter to print the node text through the use of the variable and node_load() function! Thank you kindly!