Community Documentation

How to integrate your module with Features

Last updated July 27, 2012. Created by clemens.tolboom on September 18, 2009.
Edited by nedjo, johnbarclay, coltrane, Itangalo. Log in to edit this page.

Some information is found in API.txt (DRUPAL-6--1) in the Features folder.

Making your module support Exportables

The section "Integrating your module with the Features API" in the api above outlines the basics. The handbook page on exportable configuration explains how to make the data stored in your db tables exportable via either CTools or Entity API.

If you're working with data that involves user roles, see the handbook page on exportables and user role IDs in features

To make your variables exportable, without writing any code, you can use strongarm http://drupal.org/project/strongarm. The directions on the front page of strongarm under the heading "Updating your features from Strongarm 1.x to 2.x" cover this.

To see how other modules implement features and use strongarm, do a search for:

  • features[variable][] in .info files
  • 'export' => in .install files.
  • 'EntityAPIControllerExportable' => in .module files.

A simple test module that supported features for the examples module would be a great place to start learning features

Comments

Tutorial article

I have written a tutorial article that touches upon this topic from the standpoint of someone unfamiliar with the Features module. Possibly useful if you ignore my philosophical remarks and nit-picking: Version control in Drupal 6 using the Features module.

Adding Features to support to your pre-existing module

If you just want to manage your pre-existing module, with its various views, panes, panels and content types through Features, rather than remembering to manually export each one everytime you need to deploy after a minor alteration, it won't work unless you insert

include_once('your_module_name.features.inc');

as the first line of your .module file.

When you create a Feature with your pre-existing module name, it packages all the files in your module automatically, so nothing is lost, but that crucial line is not automatically added. I spent many, many hours trying to figure out why my modules didn't deploy properly when they appeared to work on my local machine...

what about info file?

If you are just moving that line to your existing module, does either info file (your module info or the features module info) need to be adjusted in any way? Seems like it would break something.

wouldn't this be done by

wouldn't this be done by using the hook_features_api() ?

function mymodule_features_api() {
  return array(
    'mymodule_config' => array(
      'name' => 'My Module Configs',
      'file' => drupal_get_path('module', 'mymodule') .'/mymodule.features.inc',
      'default_hook' => 'mymodule_config_features_default_settings',
      'feature_source' => TRUE,
    ),
  );
}

source: http://treehouseagency.com/blog/thomas-wysocki/2010/10/28/making-your-mo...

When will this get written?

Does anyone know when this article will be written? I'm fairly new to drupal and have built a few drupal modules, but wish to know more about how to integrate them with features. Are there any other articles out there in this topic?

Much appreciated.

Have you found any useful

Have you found any useful articles on this topic? Thanks.

Tutorial

I didn't get much help out of this post so did a little more digging around and found http://treehouseagency.com/blog/thomas-wysocki/2010/10/28/making-your-mo... which is really in-depth for all those who get stuck.

......................................................................................................
Hi, my name is Marton Bodonyi and I'm an Interactive Junky.
http://www.interactivejunky.com
.........................................................

nobody click here