Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
One of Drupal's big strengths is in how well its community has adapted it for use by large organizations, what some people call the enterprise market. That market often needs to reuse work done on one site on another site. Unfortunately, it's easy for developers to step on each other's toes when working with core Drupal and their work isn't always easy to transfer. There's a great module that satisfies those needs called Features. Simply put, it takes most any settings in Drupal's database and exports them as sort of quasi modules, so they can be managed using standard file management tools for development, backing up, and so on.
Here's how it works. You first need to add the Module Features, you can get it at drupal.org/project/features. Now Features has a lot of documentation, both on the project page, and also in this documentation link. Lots and lots of stuff. This whole subsection is all about using features. Back to the Project page, one interesting thing that you see here is Other contributed modules. I'll just open that in another tab, and you see that Features actually integrates with lots and lots and lots of things.
So that you can export, for example, atrium_username and Sample Content and other stuff like that. This is what the web site looks like as I record this movie. It will certainly be different by the time you watch it, but the same stuff should be available if you search for it. But we're going to go back and just install Features. I Copy Link and install it as usual, and as always I go back and enable it. You'll notice that there's also this Features Tests module that appears after you install Features. We're going to ignore it since we're not doing any testing on the site.
So now let's create a feature. You might remember that we created a Content type called Private files in the last video. yYu can see that by going up to Structure, and Content types, and there it is Private files. I've also created a brand-new Drupal site at lynda2.tomgellar.com, and if we go up to the Structure and Content types, we see that that Content type isn't there. So we're going to move it from lynda. tomgeller.com to lynda2.tomgellar.com.
To do that, we go up to Structure and then Features. Once again, we'll ignore this whole thing about automated testing. Instead we go up to Create Feature, and I'll call it Private files. There are several options here you can add, for example, a Version number and so forth, but the thing that we're going to change is this Edit component. This says what actually goes into the feature, and in our case, it's a Content type. So we will select that, and say Private files. That gives us quite a bit of information about what exactly we're exporting, and it tells us how it's detected.
For the most part, it's all auto- detected by the Features module. If you want more information about that, of course, you'd read the documentation, which is quite lengthy. But we'll just go down and say Download feature, and that does actually download to our download location, which is on the desktop. So I'm going to go back there, and there it is, private_files.tar. Before we do anything else, let's take a quick look at what's in that feature, so I'll double-click this, and then open up the folder. As usual, there's a .info file, and also a .module file.
This is what you'd see within any kind of module that you got off of drupal.org. The big difference though is that this is a sort of quasi module, it requires the Features module in order to work. But let's open it up and just take a quick look. I'm going to open that up using TextWrangler, and it looks fairly familiar. Now I'll add that feature to that lynda2.tomgellar.com site. To do so, I'm going to go into FileZilla, my file transfer program, where I'm already logged in and see lynda2. Go into sites > all and modules, and drag and drop it as usual.
Now I will go back to the lynda2 site and take a look at what's in the Modules list. Go up to core and go down to the bottom and there it is, but you see we can't turn it on yet, because it requires Features. So I'll go ahead and grab that and install it on the lynda2 site. I'm back on the Features project page, copy the link, go back and install. Now if I go back to the Module page, I take a look. So first we turn on the Features module, and Save configuration.
Then go up to Structure, and Features, and there's the feature we just created. I'll turn it on and save settings. Sometimes you'll find that features you create have conflicts you are not expecting. In this case, I'll say, that's fine, I'll leave it as enabled. Now if we go up to Structure and Content types, so now we have the Content type successfully moved from lynda. tomgellar.com to lynda2.tomgellar.com. However, it doesn't actually bring over any content. It's really just for the structure of your site, which is why the module is called Features.
You could then bring over the content using the feeds module, as I showed you in the course Drupal 7: Reporting and Visualizing Data. It's incredibly easy once you've done this with features, because the two of them will have exactly the same field names. You don't have to rematch them up as you often do with feeds. I do have to mention that sometimes when you move things from one site to another using Features, you'll forget about dependencies. For example, in lynda.tomgeller.com, we had earlier installed the Pathauto module, and we can see that by adding some content of that Private file type.
As we scroll to the bottom we see URL path settings, and there's that Generate automatic URL alias. That doesn't actually exist in the lynda2 site, because we never installed that module. So you'll still have to go back and check your site a little bit. There's a lot more to the Features module. It does a good job of tracking changes you make for example, especially if you install another module called Diff. You can find that at drupal.org/project/diff. Now what you saw here is really the simplest used case of all. Once you start using Features, the ones you create will probably include lots of other parts, and as you saw earlier dozens of modules tie into Features.
There's also something called Features Servers, run by some Drupal Consultancies. You can see that at groups.drupal.org/node/50278. Even if you don't take advantage of Features that other people created, the Features module is a great way to modularize the way you build sites. If you find yourself doing the same thing in every site you create, start saving your own features to eliminate repetitive work and speed up development.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 105307 Viewers
56 Video lessons · 117053 Viewers
71 Video lessons · 86256 Viewers
131 Video lessons · 41232 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.