Drupal 7 Features Module Workflow
In this episode of the Daily Dose of Drupal, we go into a little more detail on the workflow of the Drupal 7 Features module that we created in the previous episode. In this episode you will learn:
- How to install a Drupal Features module you created on a new site
- What happens when you modify a Drupal features module
- What the Overridden state of a features module means
- How to recreate a Drupal Features module after you have modified it
Hello there Drupalers and welcome to another episode of the Daily Dose of Drupal brought to you by codekarate.com. This is episode 3 and today we’re going to continue looking at the Features module and it’s going to continue on what we’re working on yesterday.
So if you haven’t seen yesterday’s episode on the Features module, you may need to take a look at that first. We have our fresh Drupal 7 Installation here and we’re going to start by downloading some modules so I am going to hop on to the command line using Drush, I will download a few of the needed modules; so I’m going to download the Views, Views Dataviz, Features, Ctools and Date modules.
So run that Drush command and that will download those modules and now that’s finished up I will hop over here to the actual files, the modules directory; you can see that those modules are now there and I have also dropped in the monthly_earning.tar file that we created yesterday.
So I’m going to extract that features module here and you’ll see that the module is now extracted, I’m going to get rid of this .tar file, we no longer need that and I’m going to hop into the modules page, if I scroll down to the bottom you’ll see that in the Features section there’s a Monthly Earning module and if you look … there’s some dependencies here; one thing you’ll notice that’s missing … that we missed yesterday was the Views Dataviz module and since this is a standard Drupal module for the most part, we’re going to go ahead and add that dependency right in the .info file.
So I’m going to go ahead and open up that .info file, you’ll noticed that if you ever looked at any .info files before, it’s pretty similar, if I’m going to add the Views Dataviz module there, save that and I will refresh this page, scroll back down to the Monthly Earning module and you’ll see that Views Dataviz is now in the list of dependencies. I’m going to go ahead and turn this module on, this is going to catch all the dependencies and make sure they’re all turned on, so I’ll hit continue.
The other thing I’m going to do is go ahead is turn on the Drupal Views UI module so we can actually take a look at the view and now we will take a look and see that the Drupal Features module we created yesterday with the Content Type and the View is now available on this test2.codekarate.com website. So you’ll see there the Monthly Earnings Content Type, if you go into the views you’ll see the Monthly Earnings Report View and if you go into Features you’ll see the a Monthly Earning feature, this state or the current status is set to default and we will go over what that means here in a second but let’s go ahead and add some content to this site; so we’re going to start with the July 2012, let’s say 1,000, start also in August, go 1,500 and then we’ll do one more this time; and we’ll do September and we’ll do this 1,750, go ahead and save that one and we will now go to that monthly report and make sure that it is in fact working.
So we go to the Monthly Earnings Report, we’ll go ahead and just ignore this PHP Notice for now. There’s a Monthly Earnings Report, it’s the Pie Chart, we will compare this to yesterday’s example on the test.codekarate.com Drupal site and you’ll see that they’re different but just using the same Content Type and same Views across both.
So now what we’re going to do is we’re going to go ahead and change on the test 2 site, I’m going to go ahead and change that View and change the Report to be a Column, we’ll make this a Column Chart instead of a Pie Chart, save that and we will go back to the Monthly Earnings Report and you’ll see now we have a Column Chart. If we go back into Structure and go back to Features you’ll see that it is now in an Overwritten Status and what this means; it means that the Drupal Database configuration that contains the Drupal Content Type or the Drupal View has changed and is no longer the same as what is in the monthly_earning.module file or excuse me; the whole module … the whole Features module as a whole.
It means that the Database is in fact different, meaning that you made a change on the site that’s not represented in the code of the module. So if we go ahead and click on Overwridden it will show that the Views file is overwridden, if we go back we could recreate this if we wanted these changes to be included in the module and you’ll noticed that all the checkboxes that we had yesterday are still there, you hit Download and you’ll have a fresh new copy that’s slightly different of your new module that will have the Column Chart.
So this will download the .tar file, you could drop in to another site and this module would then have Column Chart rather than the Pie Chart. What you can also do is you can revert this back. So if we no longer want the Column Chart we want to in fact go back to the Pie Chart version, we go ahead and revert and what this is going to do is that it’s going to update the Drupal Database to represent what you have in your actual code of the Monthly Earnings module. So we’ll go ahead and revert that and you’ll see as the page refreshes it is back to the Pie Chart.
Well that’s really all there is to show today, hope you learned a little bit more about the Features module and tomorrow we will pick up where we left off and we will continue learning more about the Features module and how it can be use in deployments across Drupal sites.
So for instance if you have a Drupal Development site and a Drupal Live site and you want to move code across these different environments I’m going to show you a little bit more information on how that works using Drush and we’ll dig to the Features module a little more since there’s quite a bit to learn still.
Until next time, thanks for watching the Daily Dose of Drupal and if you like what you see you can follow me on Twitter @smthomas3 and you can also check out my other blog posts at codekarate.com. Thanks for watching.