Return to Snippet

Revision: 4538
at January 15, 2008 07:59 by berkes


Updated Code
function your_modulename_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $weight = db_result(db_query('SELECT MIN(weight) AS weight FROM {system} WHERE status = 1')) - 1;
      db_query("UPDATE {system} SET weight = %d WHERE name  = '%s'", $weight, 'your_modulename');
    break;
    default:
      drupal_set_message(t('Your database type is not supported'));
  }
}

Revision: 4537
at January 3, 2008 10:14 by berkes


Initial Code
function your_modulename_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $weight = db_result(db_query('SELECT MIN(weight) AS weight FROM SYSTEM WHERE status = 1')) - 1;
      db_query("UPDATE {system} SET weight = %s WHERE name  = '%s'", $weight, 'your_modulename');
    break;
    default:
      drupal_set_message(t('Your database type is not supported'));
  }
}

Initial URL


Initial Description
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.

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

Initial Tags
drupal

Initial Language
PHP