An Introduction to the Drupal Features Module

When you create a feature like a photo gallery, slideshow, blog or forum for Drupal, it involves installation of quite a few individual modules. In addition, each module often requires a lot of configuration.

Wouldn’t it be nice if you could just create a feature just once and reuse it time and again, no matter how many modules and much configuration it needs?

That’s the goal of the Features Module for Drupal. Create something once. Re-use it easily on as many sites as you wish.

Create a feature before you start

Before you can experience the power of this module, you need to actually create a feature. A feature might be a photo gallery, slideshow, calendar or something even more complex.

In this tutorial, we’re going to use a sliding testimonial feature. Here’s a tutorial showing how we created it: Using the Views Slideshow Module in Drupal 7. If you want to follow this Features tutorial exactly, please go through the steps of the Views Slideshow tutorial first.

tutuploadsmedia_1335312014931.png

To minimize the confusion while you’re learning, we also suggest you have a clean Drupal site to install your new feature on. It will be less complicated when you go to check your work.

Step 1. Download and Install the Features Module

Step 2. Create the Feature

Go to Structure > Features and click Create feature.

These are the settings you’ll need to enter:

  1. Name: make sure this is a unique name and not used by anything else. Do not use a term like blog or audio that might be used by a native module or one you might install.
  2. Description: Describe the package.
  3. Package: Create a group name for your feature.
  4. Version: This will actually become a module you can install, so be sure to include the actual Drupal Version here.
tutuploadsmedia_1335306874265.png

Step 3. Edit Components: Content type

  • Scroll down to Edit components.
  • Choose Content types: node.
tutuploadsmedia_1335306937502.png
  • You will see the display of the content types you have defined.
  • Choose Testimonial (or whichever one you want to build the feature for.)

tutuploadsmedia_1335307052135.png
  • Most of what needs to be included in the feature is shown as auto-detected on the right side of the screen after you choose the content type.

tutuploadsmedia_1335307097341.png

Step 4. Edit Components: Views

  • Choose Views from Edit components dropdown.
  • Choose the Testimonial Slider view.
tutuploadsmedia_1335308249840.png

Step 5. Edit Components: Add the Image Style

  • Repeat the process we used above to add Image styles: image and the testimonial_thumbnail to your feature.
  • There may be much more that needs to be added depending on the complexity of your feature. Discovering what is essential is a lot easier with the fewer components you have on the site and the simpler the feature. That’s why we suggest starting with a clean install and a new and simple feature until you get experience.
tutuploadsmedia_1335309209109.png

Step 6. Download the feature you just created

  • Scroll to the bottom and click Download Feature.
  • Download the file and save it to a directory on your computer.
  • On your other site, go to Modules > Add New > Browse and upload the file you just downloaded. It will install just like any other module.
tutuploadsmedia_1335309416806.png

Step 7. Enable the feature on the new site

  • Go to Modules after you install the feature and you will see the new feature installed. Notice that on this fresh install, I am missing a couple of required dependencies, Features and Strongarm. This won’t work until all the requirements are installed. I’ll install those now.
tutuploadsmedia_1335309811551.png

 

Step 8. Start using the new feature

  • The new feature is represented by a new content type that was automatically added.
  • All the settings and views that I created when I created the original testimonial slider are also included. I could also have included the permission settings or any other settings for components that were available in the “Edit Components” field.
  • Essentially I have “rubber stamped” the Testimonial slider and can now install it on any site like any other module. You can do this with any feature you create.
tutuploadsmedia_1335310694935.png
 

Author

0 0 votes
Article Rating
Subscribe
Notify of
13 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Daniel Sykes
Daniel Sykes
11 years ago

Thanks,

fyi – The link to the feature project is broken.

steve
11 years ago

Good catch, thanks Daniel. The link had an extra .

Yves Malouin
Yves Malouin
11 years ago

Awesome tutorial!

Keep up the great work!

preety
preety
11 years ago

how we can use different user in different themes in drupal7

chuks
chuks
11 years ago

am trying to export some features from my dev site to live site using features module. All the features i added are working except for the menu links they are not imported pls do u have any idea why

Mark Conroy
Mark Conroy
11 years ago

The Menu items don’t work properly with features as far as I know, because it’ll try to export/import the menu item as a mid – menu id – eg menu/item-123, but on the new site you might already have a menu item that has that mid.

If your feature is creating a view, then you can have the menu item in the view and it’ll be exported, saving you from individually exporting the menu as a standalone item

Mark Conroy

marcob
marcob
11 years ago

Thanks a lot for this. …stay for the community – and The System of course!

Yevgeny
Yevgeny
11 years ago

Maybe a dumb question….

It seems developers use features in the development workflow (ie – make changes on a dev instance, push changes to staging including all features, then enable features on staging site). My question is, if I never plan on reusing the feature(s) on any other site, then what advantage is there to using features over simply doing a mysql database dump on the staging (or prod or whatever) server?

Hemant Saraf
Hemant Saraf
11 years ago

One question… how do we delete the content types included by the features module…? there is no delete link in front of the content type?

Mark Conroy
Mark Conroy
11 years ago

@Yevgeny – it’s important so that content does not get mixed up with functionality. For example, if you take a dump of your DB, then make the changes, the dump the new DB on the live server, any changes made to content in the meantime will be lost (for example, if someone leaves a comment on a post, it’ll get overridden).

@hs – you should be able to do this by following this link:

[url=http://www.example.com/admin/structure/types/manage/YOUR-CONTENT-TYPE/delete]http://www.example.com/admi…[/url]

Mark Conroy
Mark Conroy
11 years ago

Oops, didn’t realise it was going to link to a site. This is the link structure:

yoursite .com /admin/structure/types/manage/YOUR-CONTENT-TYPE/delete

Caitlin Munley
Caitlin Munley
9 years ago

Thank you for this! I was having trouble understanding what Features did (it seemed redundant). Nice step-by-step guide that, by going through the steps, explains what the module does. Simple and effective 🙂

puia Chhakchhuak
puia Chhakchhuak
7 years ago

thanks

13
0
Would love your thoughts, please comment.x
()
x