Drupal Planet

For articles and entries wishing to be posted on Drupal Planet

An updated recipe for building newsletters in Drupal 7

We created the Newsletter Export module so that we could bundle Drupal website content into a newsletter. We previously blogged about the Drupal 6 version here. The module allows website managers to choose from existing website pages (any content type) which they'd like to broadcast and put it into one newsletter node for exporting. The resulting HTML content can then be imported into their usual mailing application such as CiviCRM or MailChimp.

Note that this module doesn't enable you to send your newsletter through Drupal. Neither does it allow you to maintain a list of contacts. Instead you will be required to import it into another application of your choice.

After installing the module we choose which content type we want to use as the base for our newsletters (under Configuration > Media > Newsletter Export). You can choose more than one which could be useful if you have different layouts for different newsletters. For our example we usually create a "Newsletter" content type and then choose it in the configuration.

configure article display

The basic structure of the exported HTML depends on the structure of your content type you selected to be the base content. To simplify things we will refer to that content type from now on as "Newsletter" since in our example that is what we call this content type.

Our Newsletter content type consists of an introduction and article teasers. To accomplish that, we added to the Newsletter content type a textarea field (for introduction section) and an entity reference field for linking to an unlimited number of articles. This is basic Drupal content type creation and manipulation - you can select any type of fields you want here.

The "juice" of the Newletter content are the references to other site content so that they can become newsletter teasers. We often customize the views to pull just the right content to the newsletter (for example, only last month content or content of specific type). Often, we create several entity reference fields to create sections like "News", "Blog posts", "Events" etc.

After adding an entity reference field we configure the display of the newsletter content type. Under the Manage Display tab the module supplies a view mode called "newsletter" so that there can be a view mode that is separate from what is seen by viewing the website. We configure the view mode so it shows the teaser of the rendered article that is linked through the entity reference.

configure reference configure newsletter display

You will notice that we can also choose the view mode of the referenced article node. We again choose the newsletter view mode here, but that means we also have to configure the displays for the article content type.

article display

We then create a newsletter node, let's just call it "Test Newsletter" to be boring. We also separately create a couple articles called "First article" and "Second article" so that we can reference them in the newsletter.

create newsletter

Once our newsletter is populated with our content we now have a published newsletter node. Awesome! Except now we need to export this to email client friendly HTML for our email blast. While testing the layout we first prefer to see the html inline for convenience so we change the newsletter export configuration to inline (under Configuration > Media > Newsletter Export). Users with appropriate permissions will then see a "Newsletter Export" link in the links area of content of that type. Clicking on the export link will generate an HTML file with the output of just that node.

Only after some inline testing do we change the settings for downloading the HTML and test it in our mass mailing application.

display inline

A recipe for building newsletters in Drupal

Update on April 9, 2013 - the description of Drupal 7 version of this module with links to the module files is available here

I'll start right away by saying that sending newsletters with Drupal is excruciatingly painful, and we do not recommend it at all unless you're subscriber-ship is extremely low. Many other software packages and solution providers do it much better than Drupal ever will. So this isn't about sending your newsletter, it's about how to build your newsletter for email and web delivery.

Our method is simple. Similar to modules like Simplenews we will be creating a newsletter content type that will store the contents of the newsletter. The only difference is that Drupal will not be sending the emails. We will be exporting HTML to our newsletter sending application of choice (We use CiviCRM).

The basic structure of the node depends on the structure of your newsletter. We will use our Freeform newsletter as an example. Our newsletter consists of a number of various sections almost all of which are controlled by CCK fields.

Our newsletter content types consist of:

  • Text fields for section headers
  • Textarea for header and footer text
  • node reference fields for content

Customizing WYSIWYGs beyond module settings

A large majority of features found in WYSIWYG editors are overkill for end users. With the WYSIWYG module you do have control over the display of buttons to perform functions, but that's about all you get as far as customization. Our clients liked CKEditor as the WYSIWYG editor to use, but wanted some functionality changed which was not available to us in the WYSIWYG module.

Displaying localized taxonomy terms with views

Translation support with Taxonomy can get tricky. Similar to content translation there are a few different 'modes' taxonomy translation can take. The most common mode to use is "Per language terms" where each term can be assigned to a given language. But in many cases this can be overkill as it requires that different content be assigned to each language term.

Mixed Multilingual (i18n) comments on nodes

The Problem

Our client wanted comments from multiple languages to appear together in one comment stream regardless of which translation of the node you were looking at. The current Multilingual system simply creates new nodes for each translation you create and as such if you comment on an English node it only shows on that node.

The Strategy

Bilingual content negotiation with the i18n module

The Problem

Our problem was relatively simple. Have two languages (in our case English and French, English being the default) and show all content on a site regardless of the language chosen.

Reaping the dividends of active community involvement: DrupalCamp Toronto 2010

If you have less than ten people in your company, and you send four of them to a conference, you probably consider it a large expense. Yeah, we do too. But we believe we gained much more from DrupalCamp Toronto 2010 than we put into it. We gained a deeper understanding of the open source ecosystem we're working within; new contacts with colleagues; and even met people who want to help improve our project management system for free! It's all an integral part of our pro bono practice.

Using Drupal and CiviCRM for a private web portal: Youth Science Ontario case study

We've just posted our case study of Youth Science Ontario's web portal for member organizations.

Using the Google Document Viewer with filefield to embed PDFs in your Drupal content

A recent client wanted embedded PDFs in their content so their users didn't need to download a PDF reader to just view the files. Rather than using a Flash based page turning software as they had originally wanted I discovered the google document viewer (used in Gmail and google docs) can be used to render hosted PDFs either in an iFrame or full screen on a google branded page.

Using db_set_active to move users from site-to-site

One of our clients had a need to move users from one of their drupal sites to another on their own without our intervention. The idea was that once users became alumni of the organization they would be moved from the existing community site to an alumni sub-site. The sites were setup as a regular multisite with separate databases.

Syndicate content