User login

Set weight of a Drupal module

for setting the weight of any module, as the Drupal saying goes, there's a module for that:

http://drupal.org/project/moduleweight

You can also edit the weight in the {system} table directly (and see what other modules have been set to, sorting by the weight column in phpMyAdmin).

But what about a way to set the weight of your module inside your module with code? Of course there is:

Resolution

Adapted from the devel module which notes module weights in core as new when putting itself very last in the chain.

Your module weight should be set and not change, so this goes in the hook_install function in your example.install file, say this agaric_module.install so:

agaric_module_install {
//  put hypothetical agaric module after most normal modules.

  db_query("UPDATE {system} SET weight = 50 WHERE name = 'agaric_module'");

//  ...
}

This is still the way for Drupal 6. See Drupal docs.

Searched words: 
drupal set the weight of a module drupal module weight set weight of module .info drupal

Comments

thanks!

Just what I needed!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.