diff --git a/modules/simpletest/tests/taxonomy_test.module b/modules/simpletest/tests/taxonomy_test.module index aae13a2..7cbc082 100644 --- a/modules/simpletest/tests/taxonomy_test.module +++ b/modules/simpletest/tests/taxonomy_test.module @@ -55,6 +55,34 @@ function taxonomy_test_taxonomy_term_delete($term) { } /** + * Implements hook_taxonomy_term_view(). + */ +function taxonomy_test_taxonomy_term_view($term, $view_mode, $langcode) { + if ($view_mode == 'full') { + $term->content['taxonomy_test_term_view_check'] = array( + '#prefix' => '
', + '#markup' => t('The antonym is %antonym', array('%antonym' => $term->antonym)), + '#suffix' => '
', + '#weight' => 10, + ); + } +} + +/** + * Implements hook_taxonomy_term_view(). + */ +function taxonomy_test_entity_view($entity, $type, $view_mode, $langcode) { + if ($type == 'taxonomy_term' && $view_mode == 'full') { + $entity->content['taxonomy_test_entity_view_check'] = array( + '#prefix' => '
', + '#markup' => t('The antonym is %antonym', array('%antonym' => $term->antonym)), + '#suffix' => '
', + '#weight' => 20, + ); + } +} + +/** * Implements hook_form_alter(). */ function taxonomy_test_form_alter(&$form, $form_state, $form_id) { diff --git a/modules/taxonomy/taxonomy.pages.inc b/modules/taxonomy/taxonomy.pages.inc index 0cca252..20235b4 100644 --- a/modules/taxonomy/taxonomy.pages.inc +++ b/modules/taxonomy/taxonomy.pages.inc @@ -21,6 +21,12 @@ function taxonomy_term_page($term) { // @todo This overrides any other possible breadcrumb and is a pure hard-coded // presumption. Make this behavior configurable per vocabulary or term. $breadcrumb = array(); + + // Allow modules to make their own additions to the term. + $term->content = array(); + module_invoke_all('taxonomy_term_view', $term, 'full', $GLOBALS['language_content']->language); + module_invoke_all('entity_view', $term, 'taxonomy_term', 'full', $GLOBALS['language_content']->language); + while ($parents = taxonomy_get_parents($current->tid)) { $current = array_shift($parents); $breadcrumb[] = l($current->name, 'taxonomy/term/' . $current->tid); @@ -30,7 +36,7 @@ function taxonomy_term_page($term) { drupal_set_breadcrumb($breadcrumb); drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->name); - $build = array(); + $build = $term->content; $build['term_heading'] = array( '#prefix' => '
', diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test index 9a89b9c..0516d24 100644 --- a/modules/taxonomy/taxonomy.test +++ b/modules/taxonomy/taxonomy.test @@ -909,6 +909,7 @@ class TaxonomyHooksTestCase extends TaxonomyWebTestCase { function setUp() { parent::setUp('taxonomy', 'taxonomy_test'); + module_load_include('inc', 'taxonomy', 'taxonomy.pages'); $taxonomy_admin = $this->drupalCreateUser(array('administer taxonomy')); $this->drupalLogin($taxonomy_admin); } @@ -939,6 +940,12 @@ class TaxonomyHooksTestCase extends TaxonomyWebTestCase { $term = taxonomy_term_load($term->tid); $this->assertEqual($edit['antonym'], $term->antonym, t('Antonym was successfully edited')); + // View the term + $term = taxonomy_term_load($term->tid); + $term_build = taxonomy_term_page($term); + $this->assertFalse(empty($term_build['taxonomy_test_term_view_check']), t('Antonym was success loaded for viewing for hook_taxonomy_term_view.')); + $this->assertFalse(empty($term_build['taxonomy_test_term_view_check']), t('Antonym was success loaded for viewing for hook_taxonomy_term_view.')); + // Delete the term. taxonomy_term_delete($term->tid); $antonym = db_query('SELECT tid FROM {taxonomy_term_antonym} WHERE tid = :tid', array(':tid' => $term->tid))->fetchField();