Hook_preprocess_node () execution order

If I have two modules, each of them has executed its preprocess_node hook. Then which one will be called first? Is there a way to force the order in which it will be invoked?

module1_preprocess_node(&$vars){ $vars['submitted'] = "test1"; } module2_preprocess_node(&$vars){ $vars['submitted'] = "test2"; } 

I wonder what the result will be ... test1 or test2. thanks in advance

+7
drupal drupal-6
source share
2 answers

All hooks in Drupal run in a modular manner. By default, the entire module has a weight of zero, so if you want to control the exact order in which they are launched, you need to change something in the database.

How to update module weight

If you look at the API docs for module_list () , the links break alphabetically in the name of the .module file name.

+13
source share

If the modules have not changed their weight in the system table, then the result will be test2 .

The first module called is the one that has a lighter weight; when two modules have the same weight, they are sorted alphabetically in ascending order. This is valid for each hook being called.

+2
source share

All Articles