Drupal feature Module example
Posted by drupallovers on July 13, 2012
In this example we create an Online Videos feature. The site builder configured a lot in preparation of this feature we are currently not interested in.
Step 1. admin/build/features/export
As you can see we added a name, description and a version. Next step will be defining what this feature provides.
Step 2. Select features components.
From the “Add Components” dropdown we have to select the components the feature consists off. This is about a video node so we select “Node”. From the checklist we only need the video node type.
The auto-detect functionality grabs the required building blocks node (video), content (video-field_video), modules (emvideo, features). Therefore, when we want to install the feature, we need to make sure we have installed the required modules.
Step 3. Download the feature.
When satisfied with all components, click the download button and save the tarball (in this case,
Step 4. Install and enable the feature.
Best thing to do is untar the file in your current project. As described above, features are not listed on the site/build/modules page even though they are technically modules. To keep them separate, you should consider putting all of your features in a separate directory — e.g., site/all/modules/custom/your-feature.
The feature now appears at admin/build/features. Checking the box next to the feature’s name and saving page causes the features module to check for the current state all features.
Step 5. Visit admin/build/modules
When checking for the module online video module it’s not there. Searching for the name would show you a dependency on online_video module. To disable such a module you have to disable the feature first.
- We have said nothing about what drupal projects you need to install to be able to install our example feature.
- If we had created a view this would be exported too. test it yourself.