Posts Tagged ‘Hook’

How to set the module weight in Drupal

Monday, February 8th, 2010

Drupal Hook Execution Order

Hook,Drupal,Order

Drupal widly uses the hook functions. If some hooks dependente on the other hooks, but they executed
before the dependence, it will show the error result. We should set the executation sequence of
the same hooks.

Add the following code in the module.install file:

/**
* Implementation of hook_install().
*/
function hide_clinet_relationship_install() {
// Set the module’s weight high so that it runs after other modules.
db_query(“UPDATE {system} SET weight = 9999 WHERE name = ‘hide_clinet_relationship’ AND type = ‘module’”);
cache_clear_all();
}

So the hooks in module hide_clinet_relationship will execute at last.