Assure hooks in a Drupal module are ran before the others.


/ Published in: PHP
Save to your folder(s)

Sets a module's weight to the lowest number. This assures that your module is ran before all other modules. Userfull if you want your implementation of a hook to be ran first.
Add this to your .install file. Replace your_modulename with the name of your module.


Copy this code and paste it in your HTML
  1. function your_modulename_install() {
  2. switch ($GLOBALS['db_type']) {
  3. case 'mysql':
  4. case 'mysqli':
  5. $weight = db_result(db_query('SELECT MIN(weight) AS weight FROM {system} WHERE status = 1')) - 1;
  6. db_query("UPDATE {system} SET weight = %d WHERE name = '%s'", $weight, 'your_modulename');
  7. break;
  8. default:
  9. drupal_set_message(t('Your database type is not supported'));
  10. }
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.