preprocess Vs. process functions in drupal template
What is the difference between
function mythemes_p开发者_Go百科reprocess_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.
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.
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.
Which stage of process do you want to affect, for this there are two options:
- Preprocess function: It runs first.
- Process function: Runs after all the preprocess functions have been execute.
精彩评论