Add new comment

Preprocess Functions (theme_hook) Drupal

Allow one module to alter the variable used by another module when it call a theme hook.

template_preprocess_node(&$variables) 
  -> Process variables for node.tpl.php

template_preprocess_page(&$variables)
   -> Process variables for page.tpl.php

[module]_preprocess_[theme hookname]  (&$variables)

multi-hook preprocess functions
[module]_preprocess (&$variables, $hook)

Order of preprocess execution
-------------------------------------
All Preprocess functions run before all process functions

1. template_preprocess()
2. template_preprocess_Hook()
3. module_preprocess()
4. module_preprocess_Hook()
5. theme_preprocess()
6. theme_preproces_Hook()

7. template_process()
8. template_process_Hook()
9. module_process()
10. module_process_Hook()
11. theme_process()
12. theme_proces_Hook()

Note:
In drupal 7, there are 184 theme hooks,
Many of those theme hooks are specific to a core module's usage, like theming an administration form.

Common theme hooks
---------------------------
file_link, html_tag, image, image_style, item_list, links, more_link, pager, progress_bar, table, username, user_list, user_picture

Tags

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
2 + 14 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.