Drupal - Preprocess node in module

In Drupal7, both modules and themes are able to use preprocess functions in the same way, and a given theme hook can have many preprocess implementations, originating from both modules and themes.

As with anything like this in the Drupal framework, knowing the order in which these functions run is important. Preprocess implementations from modules run first, and implementations by themes run last.

A quick search of Drupal core modules will give you examples in the node and rdf modules.


You sure can. hook_preprocess_HOOK() is what you're looking for. From the docs...

Preprocess theme variables for a specific theme hook.

This hook allows modules to preprocess theme variables for a specific theme hook. It should only be used if a module needs to override or add to the theme preprocessing for a theme hook it didn't define.

Tags:

Nodes

Theming

7