diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-10-23 15:30:34 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-10-23 15:30:34 +0000 |
commit | 435585012c75bd5073d36cf6e7500864c6332bf8 (patch) | |
tree | ecbe63762742194192f4fcb1cc4b3a6d1b629b95 /modules/taxonomy | |
parent | f914aef21b8801bf9a81ca3a4cd69484e12198c2 (diff) | |
download | brdo-435585012c75bd5073d36cf6e7500864c6332bf8.tar.gz brdo-435585012c75bd5073d36cf6e7500864c6332bf8.tar.bz2 |
#949576 by sun: Add missing hook_entity_view() and hook_entity_view_alter().
Diffstat (limited to 'modules/taxonomy')
-rw-r--r-- | modules/taxonomy/taxonomy.api.php | 28 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 4 |
2 files changed, 32 insertions, 0 deletions
diff --git a/modules/taxonomy/taxonomy.api.php b/modules/taxonomy/taxonomy.api.php index 6ceab8f80..1527e487c 100644 --- a/modules/taxonomy/taxonomy.api.php +++ b/modules/taxonomy/taxonomy.api.php @@ -183,5 +183,33 @@ function hook_taxonomy_term_delete($term) { } /** + * Alter the results of taxonomy_term_view(). + * + * This hook is called after the content has been assembled in a structured + * array and may be used for doing processing which requires that the complete + * taxonomy term content structure has been built. + * + * If the module wishes to act on the rendered HTML of the term rather than the + * structured content array, it may use this hook to add a #post_render + * callback. Alternatively, it could also implement + * hook_preprocess_taxonomy_term(). See drupal_render() and theme() + * documentation respectively for details. + * + * @param $build + * A renderable array representing the node content. + * + * @see hook_entity_view_alter() + */ +function hook_taxonomy_term_view_alter(&$build) { + if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) { + // Change its weight. + $build['an_additional_field']['#weight'] = -10; + } + + // Add a #post_render callback to act on the rendered HTML of the term. + $build['#post_render'][] = 'my_module_node_post_render'; +} + +/** * @} End of "addtogroup hooks". */ diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index b36bca9c3..1e0cf45ad 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -665,6 +665,10 @@ function taxonomy_term_view($term, $view_mode = 'full', $langcode = NULL) { $build['#attached']['css'][] = drupal_get_path('module', 'taxonomy') . '/taxonomy.css'; + // Allow modules to modify the structured term. + $type = 'taxonomy_term'; + drupal_alter(array('taxonomy_term_view', 'entity_view'), $build, $type); + return $build; } |