Last updated September 20, 2013. Created by Paul Broon on September 20, 2013.
Log in to edit this page.

What's this about?

Most of the projects I am working on involve creating a website (obviously). In most cases, the project team also requires an internal area (which might be another tutorial in the future). Out of that structure came the need to have a weekly digest of recent activities in that internal area. The users do not want to login every day to check for new or updated content and neither did they want to receive an email (via rules) each time new content or comment is added.

What's the current situation?

There are quite some modules which aim to achieve a function similar to a digest. Notifications apparently had this functionality in D6 version, but 7.x is in dev (without any change since summer 2012). I was able to get something working, using Notifiations 7.x-1.x-dev, Job Scheduler 7.x-2.0-alpha3 and Messaging 7.x-1.x-dev. However, on the specified date (or time) it wouldn't send out a single email (digest functionality) but one mail for each new content or comment.

Apparently, there's another system based on Message Notify used in Drupal Commons. You can read their blog post about that approach. Also, a bunch of developers and sponsors are working on a general approach to create digests. See the corresponding issue for more details.

Why this approach?

While the general solution seeked on the issue mentioned above is quite interesting and promising (I am trying to closely follow the development), I need a solution rather now and fairly simple as I plan to integrate it into various project websites. So I went over this problem of how I could achieve anything like a weekly digest by using only contributed modules and not writing a single line of code. As I found several requests for something like that, I thought this may help quite some other site builders and here it is.

How does it work?

My approach depends on having a designated newsletter, which is sent out on a regular basis (weekly in this example). The newsletter content is mainly a view containing contents and comments since the last newsletter. That's actually all there is to it.

Prerequisites

This setup was developed and tested using the following core and module versions.

Drupal Core 7.23
Views 7.x-3.7
for creating lists of new/updated nodes/comments
Viewfield 7.x-2.0
for embedding a view inside a node (as a field)
Views Field View 7.x-1.1
for embedding a view inside another view (Format > Show: Fields)
Simplenews 7.x-1.0
for creating a digest newsletter
Simplenews Scheduler 7.x-1.0-beta2
for sending that newsletter on a regular basis

Note: there are other modules required by these, e.g. CTools and Date. Also, Simplenews Scheduler requires at least PHP 5.3 to work.

Install and enable the modules above as normal. With Date module enabled you will need to set your time(zone) settings afterwards.

Setup & Configuration

By activating Simplenews a new default newsletter category is created. This may be used for the standard newsletter so I just created a new one: "Weekly Digest" at /admin/config/services/simplenews/add.

Next, we create two new views, one containing all nodes (examples are restricted to type "Basic Page") that have been created, updated or commented on during the last 7 days. The second view contains all comments for a node (passed by argument) from the last week. To keep this article short and save you same time, I have exported the views, find them attached to this page.

Now it is time to extend the Simplenews Newsletter content type. At /admin/structure/types/manage/simplenews/fields add a new field of type "Views". You can stick with the pre-defined default values.

Time to create the actual newsletter. Do that by visiting /node/add/simplenews and select "weekly_nodes - Page" in the newly added field. Also don't forget to select your new newsletter category. Give the node a descriptive title, explaining what is going to be digested. For my projects I am using "Internal Area" as only content types which are used internally are listed in my views. You may also add a description into the body field. Save the node and visit the newsletter tab of your new node.

There, you select the option "Send newsletter according to schedule". Below, a fieldset appears where you can set all relevant data like when it shall start being send and which interval is to be used (week, frequency 1). For title pattern I often use something like [node:title] - week [current-date:custom:W]. My Simplenews category itself is set to create the Email subject [[simplenews-category:name]] [node:title]. That way, the final subject will be something like [Weekly Digest] Internal Area - week 38 ([Newsletter category] Node title - week #). Submit your options and you are pretty much done.

Of course, you can now go ahead and setup Simplenews for example to send HTML mails, create templates for that or adjust the two new views to contain more or less information.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.