Planet Drupal

DriesNote: DrupalCon Barcelona 2015

Dries Buytaert, founder of Drupal, gave a keynote address at DrupalCon in Barcelona on September 22, 2015.  He answered what he called “three uncomfortable questions” about the state and future of Drupal, and announced that the long-awaited release of Drupal 8 is imminent, planned for October 7, 2015. The speech is available online, however, we've made it easier on you, with the following summary notes on DriesNote:

Is Drupal losing momentum? 

Basically, yes, but it will get it back.  Users are waiting for the release of Drupal 8, as it has been 5 years since the release of Drupal 7.

  • The Obsborne Effect:  the announcement of a coming new release slows adoption of the current version.  When the new release comes out, a significant spike is expected, as occurred when Drupal 7 was released in 2010.
  • Release of Drupal 8 has taken years longer than expected due to work simply not going as planned.  Unplanned and abandoned work slows the process.  Dries stated, “We can only go as fast as our slowest feature.”
  • Drupal 8 is getting more stable with 15,000+ patches contributed by 3,000+ contributors, and 1,300+ critical bugs resolved.  The last feature to complete is Twig, so Drupal 8 release is planned for October 7, if no new critical issues are discovered.

“We will fix the way we work.” 

  1. Create feature branches, and break-up feature branches.

  2. Only merge branches when they are shippable, so that the main branch is always shippable.

  3. Date-based releases will enable Drupal to be released even if every feature is not ready.  Features and patches can be added into later releases.

  4. Cross-functional teams improve continuity and follow-through.

  5. Core committers and leadership will take on the role of orchestrating and prioritizing merges.

Can Drupal compete?

Yes!  People are concerned with growth and feature development of WordPress.  However, Drupal and WordPress can’t be compared, as they serve different audiences.  There are also many other rising competitors.

  • Drupal is dominant for larger, more complex websites.
  • Drupal is advanced in its ability to scale and content modeling tools.
  • Drupal focuses on the developer.
  • To improve the User Experience (UX), Drupal needs to:
  1. Focus on the non-coders: builders, authors, and editors.

  2. Improve the UX, making it easier to use and more seamless.

  3. Let people test the UX throughout the development process, at several points prior to release.

  4. Focus on the 80% of the world that does not use a content management system, and convince them that Drupal is right for them.

“We’re in a good position, but we still need to get better at UX.  If we do, there’s a big upside.”

Is Drupal technologically relevant?

Are frameworks a threat, and how should Drupal respond to them?

  • With traditional CMS (Drupal) a UI provides content to the server, which builds the layout, adds the content, and sends it to the client.  Advantages of traditional CMS include:
    • Editorial tools, such as toolbar, preview, page layout, and edit-in-place.
    • Faster performance with BigPipe.
  • With client-side apps (Backbone.js, AngularJS, React, Ember) which are gaining popularity, decoupling occurs, so the app renders the layout and requests content from the server.  Advantages of client-side apps include:
    • Optimistic feedback.
    • Non-blocking user interfaces.
    • Application-like experience.
  • Progressive decoupling (which will be a part of Drupal 8) can achieve the advantages of both traditional CMS and client-side apps.
    • Drupal sends the layout and maintains layout tools.
    • Drupal bundles some of the more cacheable content with the layout, sending the fast content first.
    • The app requests more content.

Drupal 8 offers the options of traditional, progressive decoupling through page-building tools, and decoupled by feeding Drupal data to client-side apps.

Problem: REST APIs in Drupal 8 require multiple round-trips, and  developers lack control over the amount of data collected, resulting in a poor developer experience.

Solution in-progress:  GraphiQL, an alternative to REST, allows one API call for only the specific data desired.  This results in a better developer experience for query building.

Progressive decoupling and GraphiQL put Drupal ahead of competitors.


  1. Drupal 8 needs to be released, and momentum will come.
  2. Drupal needs to move to a more sustainable development and release process.
  3. Drupal needs to put non-coders first to increase impact.
  4. Drupal will be the go-to platform for sites and apps.

What did you think of Dries Buytaert’s talk?  What do you think about the changes coming with Drupal 8?  What features do you hope to see developed?

Drupal Theming - A Basic Primer on Template.php and Template Files

When I was first starting to dive deep into the Drupal theming layer (beyond making a subtheme and changes the styles with CSS), I found the documentation to be rather scattered. Since I'm also impatient, I wanted one place where I could go to get a quick overarching picture of what the different files in a Drupal theme do, and how a themer can use those files to bend the theme to the designer's will. 

First, basic theme anatomy

Many people subtheme Drupal's contributed themes since there are already so many great starter themes that are highly functional. Why build from scratch when others have already done much of the work for you? If you've subthemed before (read about how to create a subtheme here) you'll already be familiar with the basic anatomy of a subtheme. You have your .info file where you name your subtheme and tell your subtheme what you're using for your base theme. You can get pretty far by just doing this and then going in and tweaking the CSS/LESS/SASS.

To take theming to the next level, you'll want to understand how the template.php and template files (page.tpl.php, node.tpl.php etc) work. I've tried to break this down into a simple table that highlights the differences between template.php and template files (confusing nomenclature, yes).

  template.php Template files (*.tpl.php)
When is it run? Contains code that is run every time the template engine is run. Only runs when needed/appropriate
What is it for? template.php is a collection of functions that assist in the theming of the site. It’s for all the conditional logic and data processing of the output - the place to redefine or override theme functions, or add variables that will be made available to the theme engine. Template file(s) defines the framework of a page or region. They provide templates for various components that are made available to the page.tpl.php file, such as blocks, boxes, etc.
What are the basics of the code? PHP: This file must start with a PHP opening tag and typically does not end with a PHP closing tag. HTML only with some basic PHP to use variables, but shouldn’t have complex logic.
What does Drupal Core provide? There are default baseline variables available to all template files. Core template files.
How is the file used in the theme? There will be one template.php file for a theme, and this one file will define any needed variables. There can be none or many template files for a theme, including (but not exclusively) page.tpl.php, block.tpl.php, node.tpl.php...
What can you add or customize through this? You can add new variables and template suggestions. The layout of the specified page/node/region.

I'll walk you through template files and template.php in more detail here. We'll first start with template files (*.tpl.php) since these are the easiest to read if you're not too familiar with PHP since they are mostly HTML. 

Template Files (*.tpl.php) - More DETAILS

So now we understand that template.php and template files play distinct roles in our theme. We use the template.php for all of our conditional logic, so we keep the template files clean and looking (for the most part) like HTML. Template files, like page.tpl.php, node.tpl.php, block.tpl.php, comment.tpl.php, define the HTML for different parts of the website, and are named pretty logically. Node.tpl.php will apply to all nodes, block.tpl.php applies to all blocks, comment.tpl.php applies to all comments - you get the picture.  One thing to not get confused about here - page.tpl.php is the template file that is applied to all pages for Drupal - it's not a specific template file for nodes of the content type 'page'. 

Template Suggestions

If you want to customize the HTML for any of these regions or pages, you place the appropriate template file in the templates directory of your theme, and then customize. If you want a custom template file for the home page only (a common use case) you can create a page--front.tpl.php file. This is called a template suggestion. This will override the page.tpl.php layout only for the front page. Likewise, if you want to customize the layout of articles nodes, but no other content types, you create a node--article.tpl.php file and this will override node.tpl.php. You can get more and more specific, all based on how you name the template files. Read more on about template (theme hook) suggestions


Drupal core already provides a some baseline variables that are available to our template files. In addition, each core template files provides additional variables that are available within that template file. You can see what variables are available to the template file by looking in the comments in the /** @file **/  at the top of the template file. Often the core template file only uses a small subset of available variables, so it's worth looking to see what else you can print out. For example, the node.tpl.php file provided by Bartik is pretty simple. I know, I said template files were mostly HTML, but this sure looks like a lot of PHP. If we break it down though, there isn't any complex logic or functions here. We mainly are using the PHP opening and closing tags to print out variables. 

For example, let's print out the number of comments on a node above the comment form. We see that the variable $comment_count is "the number of comments attached to the node".​ Perfect. If we want to make the comment count an H2 to make it more noticeable, we will add the following to our node.tpl.php file:

<h2>Comments: <?php print $comment_count; ?></h2>

Refresh any page that displays a node and we'll see the following. (You may need to clear cache.)

drupal template file customization

What if we want something in a template file that isn't available as a variable? That's where template.php comes in - we can use template.php to create new variables and make them available to our template files. 

Template.php - More Details

Most themers can work with template files without much understanding of PHP. To work with template.php, some more PHP knowledge is useful, but again it's pretty basic. We put all of our functions in template.php, such as preprocess and process functions, and here we can add new variables and template suggestions. Let's break down what each of these terms means. 

Preprocess functions and variables

There are two kinds of preprocess functions you can create, theme_preprocess(), and theme_preprocess_hook().  To print out a list of available hooks on a given page, we create the simplest preprocess function (using the dpm() function requires the Devel module):

function mytheme_preprocess(&$variables, $hook) {
  dpm($hook, 'hooks');

Clear cache, refresh page and you'll get a long lists of hooks that are available. Here are just two:

drupal theme hooks

These hooks are giving us a list of all of the possible template files we could use to customize this page or region. So now, if we want our preprocess function to be only called when the page hook is called, so it will only be called once on a page load, we modify our preprocess function as follows. We'll also print out the variables that are available.

function mytheme_preprocess_page(&$variables) {
  dpm($variables, 'variables');

Now if we refresh the page, we will get a nicely formatted array of variables that are available for us to work with in our template.php. 

drupal template.php variables

Why do we care? Well, preprocess functions are great for doing things like creating new variables that we can pass to the variables array, and therefore make that variable available to our template files. Say we want to print the day of the week on our page. There currently isn't a variable for the day of the week, so we'll create one using the PHP date function. We'll then add that variable to the variables array (which we passed by reference in our function, so we can make changes). 

function mytheme_preprocess_page(&$variables) {
  $day_of_week = date('l');
  $variables['day_of_week'] = $day_of_week;
  dpm($variables, 'variables');

Refresh the page and we'll see at the bottom of the variables array we have a new variable, day_of_week. 

drupal template.php add variable

Now we can use that variable in our page.tpl.php as follows:

<h2>Today is <?php print $day_of_week; ?></h2>

I've added this just above the title. Refresh any page and you should see:

drupal page.tpl.php add variable

In case my comment above about the hooks giving us a list of all of the possible template files didn't make sense, I'll clarify here. We used a preprocess_page function, calling the page theme hook. This means this new variable will only be available to the page.tpl.php template file. If we took the same code that we placed in the page.tpl.php to add the day of the week, and placed it in our node.tpl.php, our variable would not print out and we would get an error like:

Notice: Undefined variable: day_of_week in include() (line 82 of /projects/drupal-7.38/themes/mytheme/templates/node.tpl.php).

If we want to get even fancier and print the day of the week only to logged in users, we place the logic in our template.php, and keep the page.tpl.php simple. We know we have access to the logged_in variable by inspecting our variables array that we have dpm'd out on the page

drupal template.php logged_in variable

And then we add the following code. If you refresh you'll see that logged in users can see the day of the week, but anonymous users get a snarky message. 

function mytheme_preprocess_page(&$variables) {
  $day_of_week = date('l');
  if ($variables['logged_in']) {
    $variables['day_of_week'] = 'Today is ' . $day_of_week;
  } else {
    $variables['day_of_week'] = 'You are not privy to that information';

Theme function overrides

We override theme functions if we want to change something in the layout of our theme that doesn't have a template file. There are lots of parts of the theme that don't have template files, if they are smaller bits of HTML, like breadcrumbs or the username. Here is another place the Devel and Theme developer modules comes in handy. In combo they are great for figuring out candidate template files and theme functions if we want to change something. For example let's say we want our breadcrumbs to be H3 elements, and we want to change the divider between the breadcrumb elements from '>>' to '++'. Using Theme Developer, click on the breadcrumbs to get the theme function. It's named something logical - theme_breadcrumb().

drupal devel themer If you click on theme_breadcrumb() it will send you to the code for this function on

function theme_breadcrumb($variables) {
  $breadcrumb = $variables ['breadcrumb'];

  if (!empty($breadcrumb)) {
    // Provide a navigational heading to give context for breadcrumb links to
    // screen-reader users. Make the heading invisible with .element-invisible.
    $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';

    $output .= '<div class="breadcrumb">' . implode(' » ', $breadcrumb) . '</div>';
    return $output;

To make our changes, we put this function in our theme, rename it according to our theme name, and make the desired changes. 

function mytheme_breadcrumb($variables) {
  $breadcrumb = $variables ['breadcrumb'];

  if (!empty($breadcrumb)) {
    // Provide a navigational heading to give context for breadcrumb links to
    // screen-reader users. Make the heading invisible with .element-invisible.
    $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';

    $output .= '<h2>' . implode(' ++ ', $breadcrumb) . '</h2>';
    return $output;

Template suggestions

Another thing you can do in your template.php file is add template suggestions that aren't automatically available. There are already a lot of template suggestions available - let's take node.tpl.php as an example. If we wanted to change the layout of nodes of content type article, we would make a node--article.tpl.php file. If we wanted to change the layout of a specific node, we would make a node--[nid].tpl.php file. We can access the list of available template suggestions by dpm'ing out the variables in a hook_preprocess_node() function in our template.php as follows: 

function mytheme_preprocess_node(&$variables) {

  dpm($variables, 'variables');


Inspect the variables array for theme hook suggestions and we'll see two. Note that in the array they are listed with underscores, but when we make the template files, the underscores are replaced with dashes. Also, the order matters here - Drupal will look for the most specific template first, (at the bottom of the list), and then keep working its way up. It doesn't necessarily mean that these templates exist, but that Drupal will check to see if they do. 

drupal theme hook suggestions

But say we didn't want to use either of these template files, and wanted to make a new template suggestion. For example, let's say we wanted to add a template file that would only display on the weekends, reminding people they shouldn't be inside on the interwebs, but outside doing something involving fresh air. We would add a template suggestion to the theme_hook_suggestions array as follows - note since we're adding to an array, we include an additional empty []. Also, we don't need to include '.tpl.php' in the name of our suggestion, and we're using underscores. For the actual template file itself, we will call it node--weekend.tpl.php. 

function mytheme_preprocess_node(&$variables) {
  $variables['theme_hook_suggestions'][] = 'node__weekend';​
  dpm($variables, 'variables');

Refresh, and check out your variables array - you'll see our new template suggestion is now listed. Also, since it is at the bottom of the list, it is the most specific file, so if that template suggestion and file exists, Drupal will use it.  

adding a new theme hook suggestion drupal

Great, now we can make our node--weekend.tpl.php and put in an obnoxious message like this. Note that this will replace all content that would normally be displayed by node.tpl.php and only this message will be displayed. 

custom node template file

The last thing we have to do is make sure that this template suggestion only exists on the weekends. Right now as our code was written, that template suggestion will always be there. We'll just do a quick check of the day of the week before we make the template suggestion. 

function mytheme_preprocess_node(&$variables) {
  $day_of_week = date('l');
  $variables['day_of_week'] = $day_of_week;
  if (($day_of_week == 'Saturday') || ($day_of_week == 'Sunday')) {
    $variables['theme_hook_suggestions'][] = 'node__weekend';
  dpm($variables, 'variables');

Now (as long as it's a weekend) if someone tries to view a node they will just get this - pretty annoying, huh?

using custom node template

Well, that should be a good start on your journey to becoming a Drupal theming expert. Hope you found it helpful!

MORE great resources

How to use Views RSS to create a Mailchimp RSS email campaign

Mailchimp provides a great tool for automatically sending out emails that pull information from RSS feeds (read more from Mailchimp on this topic at Create an RSS-Driven Campaign with the Campaign Builder). However, when I first tried out the Mailchimp RSS campaign builder with Drupal's out-of-the-box RSS feed, there were some things that didn't work well. I was using a image field in my blog called 'featured image', and this image was broken in the Mailchimp email, as it was using a relative URL. Also the read more link wasn't working, as it too was using a relative URL. This post will step you through how to set up your Drupal RSS Feed to display the desired information (title, featured image, trimmed body text, read more link), as well as using absolute URLs. It will also tell you how to set up your Mailchimp RSS campaign using the fields you are displaying in your RSS Feed.  


  • Views RSS module - this module provides more granular control of the fields that are displayed in our RSS feed than what is provided out-of-the-box with Views. 
  • Views RSS Media Elements module - if you want to control how images are displayed in your feed, or you have an image that is displayed in an image field (rather than in the body of your node), you'll need this as well. 

​​Step 1: Set up your RSS feed Using Drupal's Views RSS Module

1a. Views RSS: Add the desired fields

Install and enable the Views RSS, Views RSS: Core Elements, and Views RSS: Media (MRSS) Elements modules.

Add a new view (admin/structure/views/add) for your feed. Show Content of whatever type (in this case, Blog Post) you want to include in your feed. Create a page and select the 'Include an RSS feed' option. Click Continue & edit.

drupal views rss initial setup

Click on the Feed display option at the top so you're editing your Feed (rather than the Page), and then under Format click on RSS Feed. 

drupal views rss feed

Select the RSS Feed - Fields option and hit Apply.

drupal views rss feed fields

You'll be presented with a Feed: Style Options window next. Just hit Apply and we'll revisit this once we've added all of our desired fields. 

Now we're going to add our Body, Featured Image, and Path fields that will displayed in our feed. Click on the Add link in the Fields area, and select Content: Body, Content: Featured Image, and Content:Path (use Path rather than Link as it will allow us to use Absolute URLs). Click Apply (all displays). 

drupal views rss feed content

drupal views rss feed image

drupal views rss content path

For the Content: Body field uncheck 'create a label', and under Style settings, uncheck Add default classes (we don't need any added html around our fields). 

drupal views rss remove lable

drupal views rss remove default classes

Also, under Rewrite results, I'm going to trim the body to 500, since we don't want the whole blog post going out in the email. We will return to this field in a moment as well to set up the read more link, but we need to do some additional configuration first. 

drupal views rss rewrite results

For Featured Image, uncheck Create a label, and for the Formatter, select RSS <media:content> element. This is why we installed the Views RSS Media Content module - it gives us the option to format an image field with this tag. Mailchimp RSS email campaigns won't recognize image fields without the <media:content> tag. For image style, select something smallish (for this example, I used Large, 480x480) - one caveat here is that I haven't figured out how to make Mailchimp RSS email campaigns have responsive images. For Medium, select image. I don't think this is required, but I did it to be on the safe side. Click Apply (all displays).  

drupal views rss image format

Lastly for the Content: Path field, uncheck Create a label, under Style settings uncheck 'Add default classes', and under Rewrite results, check Use absolute link. We will need this in the Mailchimp campaign so our Read More link uses an absolute path. Click Apply (all displays).

drupal views rss content path

Now we'll do some quick cleanup to make sure we use absolute URLs. Rearrange the fields so Content: Path comes first. We do this so the Content: Path replacement pattern is available for all of our other fields. Click Apply (all displays).

drupal views rss rearrange fields

To get the Title to link to the absolute path, click on Content: Title, then uncheck 'Link this field to the original piece of content' - the link was broken in Mailchimp since it was a relative link. Instead of this, we will then look under Rewrite results, and select Output this field as a link. Scroll down a little to the Replacement Patterns area, and use the replacement pattern for the Content: Path (it may be different for your setup, so be sure to use what it says on your site for Replacement pattern, don't just copy what I've done here). Then click Apply (all displays).

drupal views rss replacement pattern

drupal views rss rewrite path

We will now add a Read More link to the Body. Click on the Content: Body field, and under Rewrite results, click on 'Add a read-more link if output is trimmed'. We will use the same replacement pattern here that we used above for the title, in this case [path_1], and enter in something nice like 'read more' for More link text. Click Apply (all displays). 

drupal views rss read more link

1b. Views RSS: map fields to RSS elements

Now that we've finally got all of our fields set up, we need to map those fields to the desired RSS elements. We will need this for the Mailchimp RSS template in step 2. Under Format click on the Settings link for RSS-Feed - Fields. We don't need to do anything to the Channel elements. Under Item elements: core, set title to Content: Title, link to Content: Path, and description to Content: Body. 

drupal views rss item elements

For the Item elements : media, set content to Content: Featured image. Then click Apply. 

drupal views rss elements media

Make sure to save your view, and check an <item> in the RSS that is displayed below to make sure that your title and read more links are using absolute URLs. Still with me? Now we're going to use this view to set up the Mailchimp RSS campaign. 

Step 2: Set up your Mailchimp RSS Campaign

Log in to your Mailchimp account, and click on the Create Campaign link, and then select RSS-Driven Campaign.

On the RSS Feed and Send Timing screen, enter in the RSS Feed URL - it should be something like (you can set this under the Feed settings in the Feed view you just created.) For you to be able to preview what your feed will look like, you will need to do this on a site that is available to Mailchimp, so you can't test something you're doing locally on your machine. You don't need to worry now about when you'll be sending, since we're just testing. Click Next (bottom right of screen). 

On the To which list shall we send? screen use a test group since we'll be doing testing here - don't send to your clients! Click Next.

On the Campaign Info screen, again this is just testing, so you can set it to whatever you'd like. I initially just left almost everything as defaults. Click Next.

On the Change Template screen, pick whatever you'd like, again I just left it all as default initially. Click Next.

We're finally at the place where all of our hard work setting up our feed with Views RSS is finally going to be useful. We're going to use RSS Merge Tags to customize how the content appears for the RSS driven campaign. Check out this Mailchimp article for a full list of RSS Merge Tags.

If you hover over the default text Mailchimp displays, you can then edit by clicking on the pencil icon. 

mailchimp rss email edit default

In this example, we want to display our blog post's title, our featured image, and the trimmed body text with the read more link. We'll tell Mailchimp we're going to do this totally custom, so we'll use the RSS Item tags. The image below is from the Mailchimp Merge Tags article

mailchimp rss email items

We'll open and close the RSS Items tags to start, and then put all of our custom tags in between the RSS Items tags. We want to display our Title, trimmed body (with read more link) and image, so this is what our Text should look like:

mailchimp rss email item custom text

A little explanation - if we read the documentation from Mailchimp in terms of the RSS Merge Tags, we can see the *|RSSITEM:TITLE|* looks for the RSS tag <title>, *|RSSITEM:CONTENT|* looks for the RSS <description> tag, and the *|RSSITEM:IMAGE|* looks for the <media:content> RSS tag (the media:content tag is provided by the Views RSS Media module). If we look at the XML that is output from our Views RSS Feed, we will see the fields we set previously use those exact tags. Yay!

To preview our email, click on the Preview and Test link at the top of the page, and Enter Preview Mode. Hover over your links to make sure they are linking to the correct place and you should see they are since we used absolute links in our Views RSS setup. 

mailchimp rss email preview

You can then modify your feed and Mailchimp template to your heart's content. One gotcha, the Preview option for Mailchimp seems to be cached somehow, so if you change your Views feed, to make sure Mailchimp isn't using some cached version of the feed, change the feed URL in your View, and then update the URL in the RSS Feed setting for your campaign. Kind of annoying, but it's worth it since you will be sure this way to see the updated feed preview. 





A Simple Entity Data API for Module Builders

Entity Data is a handy little API to make module builder's lives easier. If you need to build a module that adds functionality and data to an entity, no longer will you have to implement your own CRUD and export/import support.

A module builders dilemma

Fields are a powerful way to add data to Drupal entities. However, sometimes fields can be rather cumbersome. Particularly when you want to add something and thus attach fields to entities that already exists.

The alternative is to roll your own. Just use a hook alter to add UI for your data to the entity edit form using regular form API fields. Then on submit, save the data to a custom table created by the module.

This approach was the primary way of adding functionality to nodes and other entities prior to Drupal 7, before fields were in core. This technique is still utilized quite often in Drupal 7.

Each module that needs to manage entity data without fields has to implement a common pattern for properly storing data:

  • Provide a schema to create a new table to store the custom data.
  • Implement CRUD functions for saving, loading and deleting data, including deleting records when the entity is deleted.
  • Make sure the data exports and imports with the entity

A module builders dream

OK, maybe the header is a bit of hyperbole, but on recent projects were we were having to add data to nodes and various custom entities, Entity Data really made our lives a lot easier.

We created the Entity Data module to centralize the functionality in the common pattern above into a simple to use API.

The primary functions for interacting with Entity Data are:

entity_data_set($entity_type, $entity_id, $name, $value, $revision_id = 0, $language = LANGUAGE_NONE); entity_data_get($entity_type, $entity_id, $name, $default = NULL, $revision_id = 0, $language = LANGUAGE_NONE); entity_data_del($entity_type, $entity_id, $name, $revision_id = 0, $language = LANGUAGE_NONE);


They work pretty much the same way as Drupal's handy variable_get, variable_set, and variable_del. Except instead of storing data in a global context, the data is associated with an entity. And rather importantly, data is loaded only when the entity is loaded, not globally like core's variable_* methods.

In addition to using the getter/setter functions, data is auto-loaded and saved with the entity. Any data that has been saved to an entity will be automatically loaded into the entity_data property and can be accessed using:



Additionally any data added to the entity_data property will automatically be saved on entity_insert or entity_update.

This also means that entity_data is automatically exported with the entity and will be maintained on import.

So next time you have to write a module to extend entities, save yourself some time and code by letting Entity Data handle your CRUD.

Have questions or comments about Entity Data? Leave them in the comments below and we'll answer ASAP!

How to display an RSS feed in a Drupal block

If you have a standard RSS feed that you'd like to display in a block on your Drupal website, you've come to the right place. For this example, we will be using a sample feed at (excerpted here:). 

    <title>RSS Solutions for Restaurants</title>
        <b>FeedForAll </b>helps Restaurant's communicate with customers. Let your customers know the latest specials or events.<br> <br> RSS feed uses include:<br> <i><font color="#FF0000">Daily Specials <br> Entertainment <br> Calendar of Events </i></font>
    <category domain="">
        Computers/Software/Internet/Site Management/Content Management
    <pubDate>Tue, 19 Oct 2004 11:09:11 -0400</pubDate>

Let's say we want to display the two of the titles linked to the appropriate URL, along with their description, in a block like this: 

drupal feeds block with views

General Setup

We'll need the following modules:

And here is our general approach. We'll dive into the details next.

  • We will create 2 content types:
    • RSS Feed - we'll use this to tell Feeds about the XML feed we're importing
    • RSS Item - this will be the nodes for displaying the content from the feed
  • We will also create a Feeds Importer - this will tell Feeds what type of data we're importing, where we're importing it to, and how this RSS feed relates to our custom content types. 
  • We will set this up so the site checks for updates to the RSS feeds periodically using cron.
  • Last we'll create a block using views that display the most recent items in this feed. 

Feed Content Types

Why do we need 2 content types you might be thinking? Our RSS Feed content type will be very simple, we will just use it to save the URL of our feed, in this case, The RSS Item content type will be used to save the individual items in the feed. In this case, it would contain the title, description, and link from the RSS feed. So go to admin/structure/types/add and create your new content type for your RSS feed. To keep things simple, I turned off authoring information, don't promote to front page, and turned off comments. 

xml feed content type

Next create your RSS Item content type

xml item content type

This one required the addition of fields. These will match the items in the XML feed that you want to pull into each feed item. I just changed the Body field to Description, and added a Link field.

rss item fields

This matches the information in the RSS feed.

        <b>FeedForAll </b>helps Restaurant's communicate with customers. Let your customers know the latest specials or events.<br> <br> RSS feed uses include:<br> <i><font color="#FF0000">Daily Specials <br> Entertainment <br> Calendar of Events </i></font>

Set up Feeds module to import

If you haven't already, download the Feeds module and enable Feeds and Feeds Admin UI. 

drupal feeds module

We'll now configure Feeds to import at admin/structure/feeds by clicking on Add Importer, giving our importer a name, and clicking Create.

set up drupal feeds importer

After creating our importer, we'll be presented with a bunch of configuration options. First, under Basic Settings, we will attach our importer to the RSS Feed content type. I've unchecked 'Import on Submission' so we can confirm that this will work when we run cron (select As often as possible for Periodic Import so it will import as soon as you run cron). If you want your Feeds to be imported as soon as you save a new RSS Feed node, you can leave that checked. Save.

drupal feed basic settings

Under Fetcher, we'll select HTTP Fetcher, and you shouldn't need to do any configuration for the HTTP Fetcher Settings. 

Under Parser, if this is a standard RSS feed, you can select Common Syndication Parser, and there won't be any settings for this.

Lastly under Processor, select Node processor, as we will be importing the feed items into our Feed Items content type. Here we will need to do some quick configuration for the Node processor settings. These settings are a little up to you in terms of if you want to update existing nodes, text formats, and the author that will be used as the author of the nodes. The main thing is for the Bundle, you want to select the RSS Item content type. This is telling feeds what nodes to create when importing feed items. For our example, we'll select the RSS Item content type. If there is any HTML in your feed item content (like in the description) select Full HTML as the input format. Save.

 drupal feeds node processor settings

Then click on Mapping under the Node Processor - here is where we'll tell Feeds which fields to populate on our Feed Item content type with the information in the feed. The GUID is the unique identifier for each feed item, and we need to have at least one unique ID. 

Run your first import

Now, if you go to create a new RSS Feed node (node/add/rss-feed) you'll see the Feeds module has add a Feed URL required field. Enter in the URL of the RSS feed and hit Publish. If under your Basis Settings for Feeds you had checked the 'Import on Submission' option, when you saved this RSS Feed node, Feeds would have imported the new RSS Items for you, but since we left this unchecked, saving this node won't do anything except create a new node. 

drupal feeds import feed

Now, when we run cron, we'll see that Feeds will import new nodes.

drupal feeds successful

If we go to the content overview page, we'll see that 9 new RSS Item nodes have been created. 

drupal feeds new imported nodes

Display Feeds Items in Block

Lastly we'll create our block - I'll skip through the details of Views, but basically set up a view block that displays content of type RSS Item:

drupal feeds views block

And then display the title, which I linked to the 'link' field for these RSS item nodes, as well as the description.

drupal feeds set up views block

Display this block on your desired page and this is what you should see:

drupal feeds block with views

Hope this was helpful. Any questions or comments, please leave a note below!

DrupalCon LA 2015 Video: Mediacurrent Interview

In last weeks' DrupalCon interview, we featured Percona. Kyle Taylor, our Drupal Developer, caught up with Nikki and Liz and find out a little about Percona and what they do with MySQL. If you missed the interview with the Percona, Drupal AssociationLullabotPantheon, or even our first Roundtable Interview, you can catch the interviews by clicking on the links. The interviews first appeared during our week long live broadcast with Periscope and Twitter.

In our latest video interview, we feature the Mediacurrent. Kyle Taylor, our Drupal Developer, caught up with  Mark Casias and find out a little about Mediacurrent and what they do with Drupal. 

Mediacurrent INTERVIEW

Note: The video is available in 1080p HD format.


[Kyle]: Kyle, with LevelTen in Dallas, Texas. We're here talking with Mark at Mediacurrent. Mark [Casias], tell us what you guys do and interesting Drupal and etc.…

[Mark]: So we are actually a full staff Drupal shop. We work with many clients. We actually did and the NFL Project. We do marketing, we do client integration, we do development, we do pretty much the full stack. I actually run the podcast, the Mediacurrent Dropcast. We're doing a Birds of a feather on Thursday, if you guys wanna come participate, it'll be a lot of fun or it will be what we normally do.

[Kyle]: Alright. So, what kind of projects do you guys working on or what are some of the things you are building with Drupal?

[Mark]: So, we've gotta couple of projects that we're working on with the Drupal 8, we're actually starting to do development in Drupal 8. We do a lot of contributing work for the community as well. We are actually required to give back to the community as well. We're working on various educational systems, we did, that is actually in a process of wrapping down but it's still on Drupal and we've done a lot of other contributing back to the community because of it. It's been a lot of fun work.

[Kyle]: Cool! What do you think the importance of contributing back is, in terms of being in an open source community and a developer, kind of, evangelizing the community? What is the importance of contributing back to the project?

[Mark]: It moves the project forward, which moves us forward professionally, in my opinion. If we just kinda sat there and let the project scale ourselves, they wouldn't really get anything done for us in the long run, or we would be reinventing the wheel over and over again. Where we have somebody else that's working on a much better module over there, we can incorporate that, give back to them, improve that for them and ourselves as well. I think that's a main difference between our community and every other community, because we are such a do-ocracy that we want everybody to get in there and get their elbows greased up and whatnot.

[Kyle]: Yeah! So, Drupal 8, what do you think about it so far and what is the most exiting feature you are looking forward to?

[Mark]: My favorite part about Drupal 8, is one, that it is a full OOP project now. You are no longer developing with procedural code, which gets really stringy, really ugly, really quick. Then the fact that we're doing, we're getting configuration management out of the database and actually into code, which makes moving things from one area to another very very easy, which will make my life a ton easier.

[Kyle]: Ok, so, we're going to hear more about Mediacurrent and read more about you guys.

[Mark]: So, is our website and we're always around there and we have our own blog and the drop cast if you get that on iTunes, Mediacurrent Dropcast.

[Kyle]: Awesome! Thanks so much, Mark, appreciate it.

[Mark]: Thanks for having me.

[Kyle]: Thank you.

Want to listen to all of our interviews? Subscribe to our iFX Podcast on iTunes!

Drupal 8: Marketer Friendly

The digital marketing world keeps changing, basically every day, or whenever Google decides it’s time to change their algorithm. As a person who practices digital marketing, I know the challenges of working with a CMS and the need to for it to allow me to publish blog posts (like this one) easily and have it be mobile responsive, because who uses actual computers these days?

Content marketing isn’t a fad, it’s happening, right now. I’ll be honest and say sometimes working with Drupal makes it challenging when adding content. However, working with Open Enterprise, a Drupal distribution makes it a lot less complicated, especially for someone who is not technically inclined and has limited coding experience.

That being said, the announcement of Drupal 8’s features and what it has to offer seems like Drupal is making a conscious effort to make it easier on the everyday marketer. 

According to the website:

Drupal 8 allows marketers to:

  • Use the marketing software you already know.
  • Build campaigns with mobile in mind.
  • Add, remove or revise content simply.
  • Easily deliver content segmented by audience, language and device type.

Out of the many features Drupal 8 offers, my favorites would have to be the improved WYSIWYG that now comes inline images and responsive images. As well as the admin menu, which I'll get into later.

It's great to know how small or large you can make the image and the options of making them align. I should note that Open Enterprise CMS already has this feature built into the WYSIWYG. It's really great that it is now going to be a standard feature in Drupal 8. Open Enterprise CMS' image upload and size configuration looks like this:

Image Source: getCMS 

Responsive images in the WYSIWYG also make the content marketer see how their images will be seen on mobile. From the example given by Acquia, see picture below, it looks like images can be tested for responsiveness by "resizing the browser" (which we affectionately call 'twerking').

Image Source: Acquia

A feature in Drupal 8 that might not be something you think about is the look of the admin menu (see admin menu above). You're probably wondering why I like the admin bar, well, I also work with WordPress CMS. So, if you have clients that are looking to move from WordPress to Drupal sometime in the future, this nav bar will help with the learning curve of finding menu items. It looks very similar to WordPress' admin "dashboard" menu. [Note: I've been creating content on Drupal 7 sites for over a year, so I have no problem with admin menu now, but it was confusing at the beginning. There was something about the menu being on the top of the page rather than the side that threw me off. Before working on Drupal CMS, I exclusively worked on WordPress sites.]

What are some of the new elements you all are looking forward to when Drupal 8 releases? Let me know in the comments!

DrupalCon LA 2015 Video: Drupal Association Interview

Last week’s DrupalCon interview featured one of Lullabot's Technical Project Manager and Front-End Developer. If you missed the interview Lullabot, Pantheon, or even our first Roundtable Interview, you can catch the interviews here. The interviews first appeared during our week long live broadcast with Periscope and Twitter.

In our latest video interview, we feature the Drupal Association. Kyle Taylor, our Drupal Developer, caught up with Joe Saylor, CMO of the Drupal Association. In the video, Saylor talks about what the Drupal Association does for Drupal and DrupalCon.

Drupal Association INTERVIEW

Note: The video is available in 1080p HD format.

Would you rather read the interview? Read it here:

[Kyle]: So this is Kyle with LevelTen Interactive and we are talking with the Drupal Association. And I'm gonna let Joe introduce himself so, Joe. Tell us a little about yourself.

[Joe]: I'm Joe Saylor and I'm CMO of the Drupal Association.

[Kyle]:  Alright what do you guys do?

[Joe]: The Drupal Association is the kind of the legal entity behind the Drupal Project. We, our mission, is to help the Drupal Project flourish. So we provide funding for Drupal projects, we put on DrupalCon events. Both in North America and in Europe. We've also been a third kind of rotating Con what we're calling emerging markets. So we did one in Latin America last year, next year we'll be doing on in India.

[Kyle]: How many DrupalCons do you guys do a year?

[Joe]: 3 total, so one in North American, one in Europe, and then one in some emerging market.

[Kyle]: So what are some of the projects you guys backed? By the Drupal Association.

[Joe]: The types of projects that we grant, right now, we're actually really focused on Drupal 8, we have a program called Drupal 8 Accelerate. We've matched $125,00 so anybody that matches that, kicks in against that trying to raise a total of $250,000 the types of projects that get funded are really sprints. So that coders are actually getting into a room together working on the code, squashing the critical bugs. Last I heard, we're down to 27 criticals for Drupal 8. So as Dries [Buytaert] mentioned, in the Keynote this morning, fingers crossed for a Barcelona timeframe release. But it's done when it's done.

[Kyle]: So as far as the community getting involved; so like if your a developer by yourself, how do you get involved with the Drupal Association?

[Joe]: Well with the Drupal Association you can become a member, that's a great way to start. And if you want to contribute directly to Drupal you can actually look up the mentorship program on that's a way for first timers to get in and whether you want to code you can do that, you can write patches. Whether you want to contribute in some other way if you're not a coder, you can do that. You can do things like marketing, there's all sorts of ways to get involved. Whether you're technical or not.

[Kyle]: Cool, so where can we hear about the Drupal Association?

[Joe]: You can hear more about the Drupal Association at If you just go to Google and type in Drupal Association it's probably an easier way to get to it. But on the site theres some videos that explain what we do. Various pages, you can become a member there. It also likes directly to which the home of the community and you can learn lots more about Drupal and community there.

[Kyle]: Alright awesome thanks Joe.

[Joe]: You're welcome.

Want to listen to all of our interviews? Subscribe to our iFX Podcast on iTunes!

DrupalCon LA 2015 Video: Lullabot Interview

Last week’s DrupalCon interview featured friends from Pantheon. If you missed the interview or even our first Roundtable Interview, you can catch the first episode here. The interviews first appeared during our weeklong live broadcast with Periscope and Twitter.

In our latest video interview, we feature Drupal agency Lullabot. Kyle Taylor, our Drupal Developer, caught up with Lullabot’s Technical Project Manager, Darren Petersen and Front-end Developer John Hannah. They share what they do on a general day, what Lullabot does, their opinion on Drupal 8, and working with Drupal.


Lullabot Interview

Note: The video is available in 1080p HD format.

Don't have time to watch? Listen to ALL of the interviews on our Podcast: iFX Podcast!

Want to hear more podcasts? Perhaps more interviews on Drupal? Let me know in the comments!

About Lullabot

Lullabot, a U.S.-based company, with contributions to the Drupal project include: the URL aliasing system, the ecommerce package, sIFR, TinyMCE, and countless bug fixes and features, plus extensive documentation, videocasts, and the weekly Drupal podcast. 

Content Migration From One Drupal 7 Site to Another

I have first hand experience dealing with content migration, and let me tell you, it can be frustrating sometimes. If you're tired already and you're looking for ways to migrate content between Drupal 7 sites, then you are in the right place. I'm going to walk you through the steps that I had to do in order to get 500+ nodes seamlessly migrated from one Drupal site to another.

Before I start I would like indicate that I have tried using different ways, but with no luck! I tried using Node Export module and I also tried using Deploy module, but I guess the sites I've been working on were too complex or too unstable for them to function as expected. For example, the deploy module kept breaking the site whenever I attempt to fetch content, while node_export was failing silently, I submit the import form and it just reloads without doing anything at all, no errors, nothing.. Very frustrating.

So eventually I did it with XML Syndication. Here's how.


XML Syndication is the concept of having Site A's content, available through HTTP as an XML feed so that Site B can fetch, parse, and import the content. Just like an RSS feed, but more customized.

This method allows for importing one content type at a time, and it supports most field types.

Module Dependencies

Site A Steps

  1. Create a new Feature and include the content type to be migrated, along with all its field definitions; in order to replicate them on Site B.
  2. Create a new view. Add a Page display and set a path for it. Using the  Views Datasource plugin set the FORMAT to "XML data document". In the FORMAT settings, make sure to set a meaningful name for the "Top-level child element" because we're going to need it later. Don't use a pager and set the view to display all nodes.
  3. Test your view page, and make sure it displays a valid XML document that lists all the nodes to be migrated correctly.

Site B Steps

  1. Copy the Feature that you have just exported from Site A to Site B's sites/all/modules folder, and enable the feature. This should replicate the content type and all its fields.
  2. Go to /admin/structure/feeds and add a new Feed Importer. In the Basic settings of it, set "attach to content type" to use a standalone form, and check the box that says " Import on submission".
  3. Set the Fetcher to HTTP fetcher, and set the Parser to XPath XML parser.
  4. Set the Processor to Node processor, and then click on its corresponding Settings. Set the "Bundle" to the content type that was created by the Feature earlier. Set the desired Author, and disable the "Expire nodes" option. You can also choose how you want to treat existing nodes, but note that this will require you to choose a "Unique Field" in the next step.
  5. Click on the Node processor - Mapping link, and add all the content type fields as targets and set their source to "XPath Expression". Choose the field that should be unique if needed.
  6. Make sure the fields in the Node processor match the XML document fields created in SITE A STEP 3
  7. Click on the Parser settings and set the XPath expressions so that the expression in each field points to the corresponding field in the XML document. Here is an example of XPath Expressions format. In the example, the context //r  refers to the "Top-level child element" we talked about in SITE A STEP 2.
  8. Once you're done. Save your importer and go to /import. Click on the name of the importer that you have just created.
  9. Type in the URL of the XML document created in Site A.  And now you are ready to import content!!

Good Luck!! 

Have questions? Leave them in the comments below!