Hook Theme
- Function: https://api.drupal.org/api/drupal/modules[…]/hook_theme/7
- Provides preprocess and process hooks
- Execute any
hook_theme()
implementation with thetheme()
function
https://api.drupal.org/api/drupal/includes[…]/theme/7- Uses a hook name provided as the top level array key in
hook_theme()
implementations.
- Uses a hook name provided as the top level array key in
template_preprocess()
https://api.drupal.org/api/drupal/[…]template_preprocess/7- Final core preprocess function called at the end of
theme()
- Builds
$variables['classes_array']
from scratch. There is no way to push a class onto a child element. - More about
$variables['classes_array']
http://themery.com/dgd7/advanced-theming/preprocess-process
- Final core preprocess function called at the end of
Render Arrays
Note: The Form API (FAPI) makes use of render arrays.
- Documentation https://www.drupal.org/node/930760
- Drupal_render() function
https://api.drupal.org/api/drupal/[…]/drupal_render/7- Executes and processes a render array, all in one step
hook_element_info()
https://api.drupal.org/api/drupal/modules[…]/hook_element_info/7- Provide a custom render array (or Form API) element
#type
- Uses
#pre_render
hooks to prepare the data (as opposed to#preprocess
hooks) - Put expensive operations in a
#pre_render
callback for results to be cached.
- Provide a custom render array (or Form API) element
- References:
- Simple Render Array examples
http://www.vkareh.net/blog/render-arrays - Render Arrays in Examples module
https://api.drupal.org/api/examples/[…]/render_example_arrays/7 - Caching Render Arrays
http://omnifik.com/blog/render-arrays-and-cache-drupal-7 - Render API Talk
https://archive.org/details/drupalconchi_day3_the_render_api_in_drupal_7
- Simple Render Array examples
Discussion