18.10.2016 Views

Drupal 7 Module Development

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Enabling modules<br />

Just like modules can be dependencies of other modules, modules can be set<br />

as dependencies of a profile. All dependent modules will be enabled as part of<br />

the install process. The difference between module dependencies and profile<br />

dependencies is that profile dependencies can be disabled without disabling<br />

the profile.<br />

Chapter 12<br />

To add a dependency to a profile, use the dependencies field in the .info file. Here<br />

is an example from our store.info file of the modules we want enabled:<br />

dependencies[] = block<br />

dependencies[] = comment<br />

dependencies[] = contact<br />

dependencies[] = contextual<br />

dependencies[] = dashboard<br />

dependencies[] = help<br />

dependencies[] = image<br />

dependencies[] = menu<br />

dependencies[] = path<br />

dependencies[] = taxonomy<br />

dependencies[] = dblog<br />

dependencies[] = search<br />

dependencies[] = shortcut<br />

dependencies[] = toolbar<br />

dependencies[] = overlay<br />

dependencies[] = field_ui<br />

dependencies[] = file<br />

dependencies[] = rdf<br />

By default, the field, field SQL storage, filter, list, node, number, options,<br />

system, text, and user modules are enabled. Any other modules you want<br />

enabled need to be listed in the .info file for the profile.<br />

Ensuring profile dependencies<br />

Since dependencies of profiles can be disabled, profiles that rely on<br />

dependencies should ensure that a module is enabled before acting on<br />

it. The function module_exists() can be used to test if a module is<br />

both installed and enabled. For more details on module_exists() see<br />

http://api.drupal.org/api/function/module_exists/7.<br />

[ 347 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!