Monday, May 30, 2011

How to update a module's weight

How to update a module's weight

In Drupal, the order in which a module's hooks get called is dependent on the weight of your module in the system table. You can set a low weight (including negative numbers) to get your module to execute before others. Or, you can set a high weight to execute after other modules.

Note: In Drupal 7, modules can vary the weights of their hooks to be more flexible.

Code to update weight

You will want to modify and then place this code into your module's modulename.install file in a modulename_install function. See more details on the hook_install in the hook_install API documentation.

UPDATE system SET weight = [yournumber] WHERE type = 'module' AND name = 'yourmodulename';


No comments: