2

I am trying to get a Drupal to run a custom hooks; one that needs to run when a module is being installed and another for when the module is being unistalled. Is there a hook or a trigger that I can use to have Drupal run the hook while the module is installing or uninstalling? The hook that I need to run builds taxonomy terms from an array. I am basing the lay out on the hook_schema. An example of the implementation of this hook is:

function mymodule_install_taxonomy() {
    return array(
         <<Taxonomy Structure Here>>
    );
}

This code would be placed in the .install file.

1 Answers1

4

When your own module is installed or for others?

For your own, there is hook_install() (only called the first time your module is installed, usually used to install the schema defined in hook_schema() in Drupal 6, this is automated in Drupal 7), hook_uninstall(), hook_enable() (called every time your module is enabled) and finally hook_disable() (when your module is disabled).

Drupal 7 has also added a similar set of hooks that is however called when other modules are installed, uninstalled, enabled or disabled, see hook_modules_*()

Berdir
  • 6,881
  • 2
  • 26
  • 38