If I have two modules, each has implemented its preprocess_node hook. Then which one will be called first ? Is there anyway to enforce the order in which it would be called ?
module1_preprocess_node(&$vars){
$vars['submitted'] = "test1";
}
module2_preprocess_node(&$vars){
$vars['submitted'] = "test2";
}
I wonder which would be the result... test1, or test2. Thanks in advance
All hooks in Drupal are fired in module-weight order. By default, all module's have a weight of zero, so if you want to control the exact order they fire in, you need to change something in the database.
How to Update a Module's Weight
If you look at the API docs for module_list(), ties break in alphabetical order of the filename of the .module file.
If the modules didn't change their weight in the table system
, then the result will be test2
.
The first module invoked is the one with a lighter weight; when two modules have the same weight, they are sorted by alphabetical ascending order. This is valid for every invoked hook.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With