Modes: A Super-Features Module

Component ID

1195396

Component name

Modes: A Super-Features Module

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Downloads

701

Component created

Component changed

Component body

Modes allows creating mutually exclusive Features. The goal is to create site "modes" -- typically collections of features that together compose a certain type of site. Because only one Mode can be enabled at a time, this allows administrators to switch between different site Modes, changing the type of site they're on. For example, this module could allow switching from a blogging site to a microblogging site by just clicking a radio button.

Details and Configuration

Each Mode is really a Feature module -- a bundle of settings and exportables. This makes the module very lightweight while being extremely flexible.

After installing the Mode module, you will have a new option when creating Features called "This feature is a mode" in the "Modes" group. Selecting this option will make your Feature into a Mode.

To enable your Mode after uploading it to your site, select it from the list of Modes at admin/settings/modes or call modes_set($mode_name) from code. (Use modes_get() to get the currently enabled Mode in code.) Only one Mode can be enabled at a time. Modes do not show up at admin/build/modules or admin/build/features.

Enabling a Mode will do two things: it will enable the associated feature (and disable the feature associated with the previously selected Mode, if applicable); and it will add a class to your site's tag if your theme uses the $body_classes variable in page.tpl.php (unfortunately, Garland doesn't, but most themes do). This class allows you to theme your site differently depending on which Mode is enabled.

Roadmap

The module is currently stable.

Future enhancements may include the ability to create multiple collections of mutually-exclusive Features.

I do intend to create a Drupal 7 version of this module. Patches are appreciated.