15

What is the difference between

function mythemes_preprocess_html(&$variables) { ... }

and

function mythemes_process_html(&$variables) { ... }

in drupal 7 template.php.

when must use preprocess functions and when must use process functions.

thanks.

Questioner
  • 225
  • 4
  • 10

3 Answers3

12

They're effectively the same thing albeit called in different phases. Preprocess functions are called first and changes are made. Process functions are then called at a later phase and allow for changes to be made to alter any modifications introduced during the preprocess phase.

See http://drupal.org/node/223430 for more information.

1

More exactly, from Drupal API documentation:

If the implementation is a template file, several functions are called before the template file is invoked, to modify the $variables array. These fall into the "preprocessing" phase and the "processing" phase, and are executed (if they exist), in the following order (note that in the following list, HOOK indicates the theme hook name, MODULE indicates a module name, THEME indicates a theme name, and ENGINE indicates a theme engine name): (source: http://api.drupal.org/api/drupal/includes!theme.inc/function/theme/7)

And if you follow the link above, it will list, in order, the entire theme() progression, from process functions to preprocess functions to the template file itself.

Joe Hyde
  • 999
  • 7
  • 17
0

Which stage of process do you want to affect, for this there are two options:

  1. Preprocess function: It runs first.
  2. Process function: Runs after all the preprocess functions have been execute.