Drupal 7 Features Module Introduction

By shane
Thu, 2012-09-06 15:11
1 comments
Daily Dose of Drupal Episode #2

Daily Dose of Drupal episode 2 looks at the Drupal 7 Features module and how it can be used to easily deploy common configurations across multiple Drupal sites.

Hello there my fellow Drupal developers this is the Daily Dose of Drupal, Episode 2. Today we’re going to be talking about the Drupal Features module; the Features module is useful for a few different use cases but the first one we’re going to talk about is anytime you want to build something and re-use it across multiple Drupal websites; so this could be a blog, an image gallery or really any configuration of content types of views and other “features” that you may want to use across multiple Drupal websites and that’s going to be what we’re going to go over in this episode.

In the next episode we’re going to go over how this can be used to move this configuration across multiple environments. Let’s say you have a development and a live environment, you make a change to a content type or a view on the development environment, and then you can use a Features module to roll those changes up into the live environment. But we’ll go ahead and get started here and as you can see I used Drush to download the Drupal Features module and then I enabled the Features module so it should be there on our site and if you’re a Drupal developer and you don’t know what Drush is, you should definitely look into it as it will help you and just make your life easier.

So we’ll go ahead and we’ll check to make sure that the Features module is in fact installed, which it is and we’re going to use the content types and views that we created in the previous Daily Dose of Drupal, so I have a content type called Monthly Earnings and I also have a view called Monthly Earnings Report.

So we’re going to go ahead and go under Structure, click on Features and here’s a list of any features that you have installed on the site, we don’t currently have anything here so we’re going to click on Create Feature, we’re going to call this Monthly Earnings, I’m going to give it a description, you can select which package you want, you can give an optional version or the URL of the Update XML and that’s if you have this features hosted on a feature server and you’re going to be providing updates, we’re not going to worry about that and now we go through the different components. So for instance we’re going to start with Content Types; we want to export our Monthly Earnings; if there’s any dependencies of modules that are needed you can see that over here it already picks a lot of them for you and most of the time it should be pretty much automatic.

For instance; the Date module, the Features module of course and a few other dependencies that are needed. You then can select the fields so we’re going to select the two fields on the Monthly Earnings Content Type; the Month field and the Amount field, we’re going to go ahead and we do not have any Image style, we’re not going to be exporting any Manual Links or Menus, we’re going to skip the Permissions and the Roles as well as the Filter Formats and we’re going to go directly to the views. So we’re going to click on the Monthly Earnings Report View and we are going to go ahead and download this feature. As you can see I now have this monthly_earning.tar file that has just been downloaded to my computer.

So I’m going to go ahead and open that up; you can see that there’s a couple of files in here and basically what this does is it creates a module for you that you can then drop in and install on any Drupal website and this contains all of the code; so once you turn it on another sire you’ll have the same set up and the same configuration that you currently have.

So as you can see this is useful for a wide variety of things; if you build a lot of Drupal client websites and you intend to rebuild the same things like maybe it’s a View Slideshow and you want to reuse that slideshow on multiple sites, you only have to build it once, export it as a Feature and drop it in wherever it’s needed. Well it was short and sweet this time on the Daily Dose of Drupal and we’ll be back tomorrow with another video for you. Thanks for watching.

Need to learn more Drupal?

Premium Drupal Training Online (Horizontal)

Comments

This is a really good video to understand Features easily !

Post new comment