Subprofiles makes it possible to provide different flavours, called subprofiles, of a given installation profile. Subprofiles are defined in the profile's .info file, and consist of a set of features available for enabling, with a default enable status. In an interactive install, the site configuration form includes elements to select which subprofile to install and can further specify exactly which of the subprofile's features to enable.

You won't typically need to download and install this module--if it's needed, it should be already packaged with the version of Drupal you're installing.

Developer instructions

To add subprofiles support to your installation profile:

  1. Edit the profile's .info file and make the following additions:
    • Add subprofiles as a dependency:
      dependencies[] = subprofiles
    • Add a section specifying the available subprofiles. A 'standard' subprofile is required and will be used if no subprofile is specified.
      subprofiles[standard][name] = Openoutreach standard
      subprofiles[standard][description] = Install a full version of Open Outreach with all commonly needed features enabled.
      // A feature called feature_x that should be enabled by default.
      subprofiles[standard][features][feature_x] = TRUE
      subprofiles[standard][features][feature_y] = TRUE
      // A feature called feature_z that should be available but disabled by
      // default.
      subprofiles[standard][features][feature_z] = FALSE
  2. In your .profile file, or an include file loaded at install time, add an
    install task:
    /**
    * Generate an install task to install subprofile features.
    *
    * @param $install_state
    *   An array of information about the current installation state.
    *
    * @return
    *   The install task definition.
    */
    function example_install_tasks($install_state) {
      $tasks = array();
      // Add Subprofiles tasks.
      require_once(drupal_get_path('module', 'subprofiles') . '/subprofiles.install.inc');
      $tasks = $tasks + _subprofiles_install_tasks($install_state);
      return $tasks;
    }

Drush support

To use Drush support, you must move the subprofiles.drush.inc file that comes with subprofiles to a location accessible to Drush.

Here is an adapted excerpt from the relevant section of Drush help:

You can put this file in a number of places:

  • In a .drush folder in your HOME folder. Note, that you have to make the .drush folder yourself (so you end up with ~/.drush/subprofiles.drush.inc).
  • In a folder specified with the include option.
  • In /path/to/drush/commands (not a Smart Thing, but it would work).

When subprofiles.drush.inc is accessible to Drush, you can install or reinstall an installation profile with the following command.

drush subprofiles-site-install [profile_name] [subprofile_name]

The --features option can be used to specify exactly which of a subprofile's features should be enabled.

For example, to install the minimal subprofile of the openoutreach profile with only the debut and debut_article features enabled:

drush subprofiles-site-install openoutreach minimal --features=debut,debut_article

Similar projects

The Profiler project can be used to create a relation of dependency between different install profiles, where "one Profiler Install profile inherits from and extends another Profiler Install profile."

Both Profiler and Subprofiles can be used to create a variety of related install options. Differences include:

  • While Profiler can be used to relate different install profiles, Subprofiles makes it possible to have multiple variations of a single install profile.
  • Profiler includes methods for creating types of entities not covered by features (nodes, taxonomy terms, etc.).

Since they largely address different needs, Subprofiles and Profiler can be used together in the same installation profile.

The Apps module provides support for multiple apps (bundles of configuration and functionality) that can be selected at install time from multiple providers. See #1444770: Enable multiple install-time profiles in Apps for discussion of merging Subprofiles-like functionality into Apps.

The Feature set module allows a profile to declare multiple sets of features in a similar format to that used by subprofiles. A feature set may include multiple features and other dependencies.

Project Information

Downloads