We've got a nice little app working now, using our service container well. Good work! In this final lesson for this series we're going to have a review of working with containers. We'll look at why this is such a good practice, discuss model classes versus service classes, and take a moment to acknowledge best practices versus the real world implementations you can end up with.
Additional resources
In this PHP tutorial we are going to continue to remove the flat functions in our code. We'll refactor one of them to a private function and create a new ShipLoader
service class to clean up the rest. With this refactoring in place, we'll be able to rename the functions.php file since it won't contain any functions any longer.
In this PHP tutorial we're going to update some information in our ship object and see another way that objects are different from arrays—objects are always passed by reference. We need to add a new feature to our app so that after the battle we can display the final health of the battling ships. One will be zero or negative, but how much health did the other have left? Let's take a look at how we can update the ships to reflect their new health after a battle.
Object-Oriented PHP Part 2
CourseMost written text has a lot of functional words, like "a", "the", or "is" which are important to the person reading the content as they help it flow in a cohesive manner, but aren't necessary as important to someone searching the content of your site. In this tutorial we'll look at ways to ignore those words in our search index.
Drupalize.Me Update, July 2015
Blog postIt's that time again! Here's an overview of what we've been working on recently at Drupalize.Me.
React.js, CouchDB, Node.js, de-coupling Drupal; if any of that sounds cool to you, then this is the podcast for you.
This week we'll be continuing our Using MailChimp with Drupal 7 series. And like last week, all the tutorials are free. Last week we looked at creating, and collecting contacts for, a MailChimp mailing list. This week we'll look at all the different ways we can send email to our lists.
One of the best features of MailChimp is its awesome template creation tools, and their ability to allow anyone to create beautiful email templates. Unfortunately, the templates created in MailChimp are not supported by the Drupal MailChimp Campaign module without a little extra work. In this tutorial we'll take a look at creating a template in MailChimp using their drag and drop template creator. Then, we'll walk through the extra steps required in order to have these custom templates you create available in Drupal when using the MailChimp Campaigns module to send a campaign.
In addition to just making the templates appear in Drupal, we’ll also want to declare which regions in the template should be editable within Drupal. So we’ll use the mc:edit=""
HTML attribute in our template. Any DOM element we add this attribute to will become a section, which content creators on our Drupal site can insert content into.
By the end of this tutorial you should be able to create a custom email template in MailChimp and know how to make it show up as an option in Drupal. You should also understand how to edit your template's code to include editable regions that Drupal can display and editors can use.
Further your learning
- Why do you need to export a template to HTML and then re-import it?
- What does the custom `mc:edit` attribute do in an HTML email template?
- Further exploration: Can you create a new template that is a 2x2 grid, and make that template available to someone creating an email campaign in Drupal?
Additional resources
MailChimp has the ability to trigger a webhook, or push notification, whenever someone takes an action on their MailChimp account. For example, when someone unsubscribes from your mailing list by clicking the link in their email, instead of logging in to their Drupal account and using the checkbox provided there. Drupal, can be configured to listen for these webhook notifications, and take action whenever one is received. This is particularly useful for allowing Drupal to update cached data about subscribers in real time.
If you're using MailChimp with Drupal I highly recommend configuring the webhook integration. It helps to keep the information contained in Drupal and in MailChimp in sync. And, it is super easy to do. In addition, whenever a notice is received, the MailChimp module triggers hook_mailchimp_process_webhook()
, documented in mailchimp.api.php
. This allows your custom modules to respond to someone subscribing or unsubscribing from your mailing list in any way you want.
In this short tutorial we'll look at how to enable web hooks for your lists in MailChimp, and then talk about why this is an important feature to enable.
In order for the webhook integration to work your Drupal site needs to be accessible to the internet so that it can receive HTTP posts from MailChimp's API.
By the end of this tutorial you should be able to configure Drupal to respond to MailChimp webhook notifications.
Further your learning
- Why is it important to configure the MailChimp webhooks?
- Can you give an example of an action that would cause a MailChimp webhook to be triggered?
Using the MailChimp Activity module we can allow site administrators to view activity and statistics for any Drupal account subscribed to our mailing list, or any entity for that matter. In our example we only have user accounts subscribed at the moment though.
Once enabled, and configured, the MailChimp Activity module will display a tab for each user account with details about what emails they have received and whether they have opened them or not. This is a subset of the data that MailChimp collects for us to help analyze the success of our campaigns. It's only a small portion of the data available, but it's nice to be able to see it right in Drupal. It also opens up the opportunity for content creators who have access to Drupal, but not MailChimp, to see how their email campaigns are performing.
In this tutorial we'll take a look at enabling the MailChimp Activity module, configuring it to display the information we want, and the permissions that it provides to determine who is allowed to view these statistics on your Drupal site.
By the end of this lesson you should be able to navigate to the "MailChimp Activity" tab for any user of your site and get a report of their actions on your mailing list.
Further your learning
- Why would you want to show a user's MailChimp activity in Drupal instead of MailChimp?
- What new permission(s) does the MailChimp Activity module add and what do they allow?
- Further exploration: What happens if you create a MailChimp Activity entity for a entity type + bundle that doesn't have a MailChimp Lists field attached?
In an earlier tutorial, we looked at sending emails from the MailChimp UI. Now let's look at sending a campaign to our MailChimp list via Drupal. In this tutorial, we'll enable the MailChimp Campaigns module, and send a campaign through the Drupal UI. We'll also talk about the various advantages and disadvantages of doing it this way vs. via the MailChimp UI. The big win is that your site's administrators don't have to know anything about MailChimp, instead they can just do all their work right in Drupal. There is also the ability to use a token-like syntax to include the content of existing nodes on your Drupal site rather than copy/pasting their content into MailChimp.
By the end of this tutorial, you should be able to send a MailChimp email campaign via Drupal, and understand the advantages and disadvantages of this approach in order to help you decide which method is best for you.
Further your learning
- What additional permission(s) does the MailChimp campaign module add, and what do they allow?
- What are the two primary advantages to sending email campaigns through the Drupal UI?
- Explain the use case for the MailChimp text format. What does it allow that other text formats do not?
- Further exploration: Can you use Views to create a list of archived/sent campaigns that is available to the public on your site?
Additional resources
The MailChimp Lists module provides integration with the Views Bulk Operations module. This integration allows site administrators to create a view, and then use the contents of that view to create a new segment for a list in MailChimp. This is pretty cool because there are a lot of things that Drupal knows about your users that MailChimp doesn't. So we can begin to use the powerful Views module to create list segments that might otherwise be impossible to generate.
In this tutorial we'll install the Views Bulk Operations module (VBO) and it's dependencies. Then, we'll create a view of users on our site that can be filtered based on the user's role. Finally, with the VBO integration, we can use this to create a new segment in our mailing list for just users on our site with a specific role.
By the end of this tutorial you should be able to create a new list segment in MailChimp based on the content of a view in Drupal.
Further your learning
- What does the Views Bulk Operations module do?
- Can you list three examples of list segments you could create with the information in Drupal that you couldn't create directly in MailChimp?
- Further exploration: Can you create a view that allows administrators to create a new MailChimp segment that contains only users who logged in to your site in the last month?
Additional resources
Before you start sending email newsletters to your mailing list, it's a good idea to have a plan, set some goals, and understand what you're trying to accomplish. In this tutorial, you'll get a quick primer on email marketing and the things you can do to ensure your campaigns are successful.
I’m not an email marketing expert by any stretch of the imagination. But there are lots of suggestions in here that will help you further your own research into creating successful campaigns, as well as some good ideas about where to start. If you’ve never planned an email marketing campaign, then this tutorial is for you. If you’re an experienced veteran, there may be some good refreshers in here. You can also skip ahead to the next tutorial and start sending emails.
Further your learning
- List three things you should do as part of the copy editing/review process every time you send a campaign.
- What are some things you can do to prevent your emails from being labeled as SPAM?
- Further exploration: Write a draft set of guidelines for you or your team to follow when preparing to send a new email marketing campaign.
Additional resources
There are two ways you can send an email to a MailChimp list: through the MailChimp UI, or via Drupal. In this tutorial we'll look at using the MailChimp UI to send an email campaign to our mailing list. We'll also use MailChimp to segment an existing mailing list into smaller, more targeted, groups to send a campaign to, allowing us to be more effective with targeting those users on our list that we know will care about a specific announcement.
The MailChimp UI for composing and sending an email campaign is awesome, and has some great tools for content creators. In this tutorial we'll choose a a template, draft a newsletter, send a test email, and then finally send the real thing.
After that, we'll look at how we can use the values of the merge fields associated with subscribers in our list to segment the list and send a campaign to just the people in a specific location. Or example use case is that our hypothetical ice cream store has physical locations in Aspen, Carbondale, and Glenwood Springs. When a user signs up for our mailing list they can optionally let us know which store, or stores, they frequent. Then, when our Aspen store has its two year anniversary, and we're going to offer specials at just that store for the weekend, we can email our list and let them know. Rather than spam the entire list, we can target just those people who have identified that they frequent the Aspen location. Pretty cool.
By the end of this tutorial you should be able to send a new email campaign from within MailChimp to your list of subscribers, as well as know how to leverage list segmentation.
Further your learning
- Can you give two example use cases for list segmentation?
- What are the different ways that you can preview an email campaign in the MailChimp?
- What are merge tags in MailChimp?
- Further exploration: Explore the various templates and themes provided by MailChimp. Are there any that would serve as a good starting point for your email campaigns?
Additional resources
MailChimp offers the ability to set up RSS-based email campaigns that automatically send daily, weekly, or monthly emails to your subscribers based on the content of an RSS feed. In this tutorial we'll look at creating an RSS feed of ice cream flavor updates in Drupal using Views, and then configuring a campaign in MailChimp to use the content of that RSS feed to send a daily email to anyone subscribed to our Flavor of the Day list.
I'm not going to cover creating an RSS feed in Views during this tutorial. Instead I assume that you've already created the necessary feed on your own site. If you’re not familiar with creating feeds with Views check out this video tutorial, Creating Views Attachments, which demonstrates how to create an RSS feed in Views.
In order for your RSS-based campaign to work, your Drupal site needs to accessible to the web, so that when MailChimp tries to read the content of your RSS feed, it can do so. If you're just testing this out, you can use a tool like ngrok.com, or just create a dev site on Pantheon or Acquia to play with.
By the end of this tutorial you should be able to create a campaign in MailChimp that pulls data from an RSS feed in Drupal and sends an email with that data to your mailing list on a regular basis.
Further your learning
- Give an example of a use case for RSS-based campaigns that would be useful for your users.
- What do you need to do on the Drupal side of things in order to create an RSS-based campaign?
- Can you send an RSS-based campaign to a segment of a MailChimp list?
- Can you test an RSS-based campaign with a Drupal site on your localhost?
- Further exploration: Can you add an RSS feed to a regular campaign template? Hint: *|RSSFEEDBLOCK|*
Additional resources
- Creating Views Attachments, covers how to make an RSS-feed in with Views
- MailChimp documentation for creating an RSS-driven mail campaign
- MailChimp's Merge Tags for RSS-driven campaigns
- MailChimp's RSS item tags
Tutorial: Panels as Blocks
Blog postIn this tutorial, you will learn how to place panels in any region of your theme using Drupal's Blocks UI and a module packaged within the Panels project: Mini Panels. This tutorial is based on a free video in our library, Placing Panels in Blocks with Mini Panels
This week we're kicking off our new, and completely free, Using MailChimp with Drupal 7 series. This series will teach you everything you need to know about integrating Drupal with the MailChimp email marketing service.
MailChimp allows us to collect additional information about contacts that are subscribed to a list. Similar to Drupal's Field UI you can add any number of new data points, called merge fields, to a contact in MailChimp. In this lesson we'll look at how to configure merge fields in the MailChimp UI, and then demonstrate how to synchronize the value of a field in Drupal with the MailChimp merge field. This will allow us to create first and last name fields in Drupal that keep the contacts information up to date in MailChimp.
Then, we'll install the date and Token modules, and add a Birthday field to our Drupal user entities. This will allow us to look at some of the more complex configuration options available when merging field values in MailChimp. By checking the advanced option on the form for configuring the mapping of Drupal field values to MailChimp merge fields we can allow users to use Drupal 7 tokens. This opens up all kinds of new options for massaging the data within Drupal a little before sending it to MailChimp so that we can match the format that MailChimp's API expects the data to be in.
For example, we’ll use tokens to customize the format of a Drupal date field, which stores its value in the database using ISO Date format, so that it matches the MM/DD
format that MailChimp expects, using a token like the following: [user:field-birthday-iso:custom:m]/[user:field-birthday-iso:custom:d]
If you're using the advanced field mapping form I highly recommend that you also install the Token module. The MailChimp module provides integration with the Token module’s UI for browsing the list of available tokens, making it much easier to create complex mapping patterns.
By the end of this tutorial you should be able to add additional merge fields to a MailChimp list and keep the content of those fields in sync with fields from a Drupal user account.
Further your learning
- What is the use case for merge fields?
- List the three merge fields that are added to every MailChimp list by default? Which of these is required, and why?
- When you are configuring the mapping between a Drupal field and a MailChimp merge field using the select list interface the list is populated with a variety of options. Where do these options come from, and what do they represent?
- Further exploration: Can you setup Drupal to collect a users address/location and then merge that data into MailChimp using a MailChimp address merge field?