2

I am looking for solution how to change particular module's weight in D7. I know that it is possible to do in config tables in database, but I don't know how. Another solution that I found in Drupal.org is to use hooks - but I need more detail explanation or some guidance where I could get some tutorials about that.

The thing that I need to do is to make some priorities of some particular modules higher for it to load faster than other modules as otherwise they will not work. One of the examples is video streaming using Lightbox2 popup watching that on Safari browser on OS X - it's not loading until you change the priority of Lightbox module.

1

4 Answers 4

1

If you have access to phpmyadmin, you can look through the system table and when you find your module, you can click the little pencil icon to edit the row in the table. You would edit the weight column.

1
  • Thank you! At least I know where to look. Now I face another problem- one of the things I would like to change the weight is Lightbox2 module, but it looks like there is no such thing in tables - even though that it is enabled and fully funcioning... Commented Oct 23, 2011 at 12:12
3

Since it was explicitly asked, there is also a module, Modules weight, that performs this task as well.

We always need to modify modules execution order, and some could write a code that execute a query to modify the weight of a module in system table, some might go straight to his favorite SQL client and modfiy the record directly, This module provide admin interface for users/people has the access to modules page to reorder the module weights as they want

1

What I have seen in different modules is that they do it directly in the database with a db_query call. Something like:

db_query("UPDATE {system} SET weight = 12 WHERE name = 'admin_views'");
2
  • Well, but how to do that, the problem is that I'm not sure, how to make changes directly in the database... Commented Oct 19, 2011 at 14:29
  • 1
    If you are writing a module you can take my code and use it in e.g. a hook_install() function. If you want to do it directly in the database, you could install the devel module and use this to execute my code as PHP. If you are running a mysql server you'll properly have access to a tool like phpMyAdmin, from where you can run a SQL query, then run: UPDATE system SET weight='wanted weight' where name = 'module machine name'
    – mtrolle
    Commented Oct 19, 2011 at 18:18
1

You can use drush for this job as well. Use the commands below, and adapt the values of modulename and moduleweight to your liking:

  1. Look up the current weight of your module:

    modulename="rdf"
    drush php-eval "drush_print_r(db_select('system', 's')
      ->fields('s', array('weight'))
      ->condition('name', '$modulename', '=')
      ->execute()
      ->fetchField()
    );"
    
  2. Set the new weight of your module:

    modulename="rdf"
    moduleweight="1"
    drush php-eval "db_update('system')
      ->fields(array('weight' => $moduleweight))
      ->condition('name', '$modulename', '=')
      ->execute();"
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.