Created
July 11, 2013 14:14
-
-
Save jekamozg/5975812 to your computer and use it in GitHub Desktop.
Drupal 7 taxonomy term link rewrite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implementation of hook_entity_info_alter(). | |
* | |
* Redirect any links to program taxonomy terms to their corresponding node page. | |
*/ | |
function content_recipe_entity_info_alter(&$entity_info) { | |
$entity_info['taxonomy_term']['uri callback'] = 'content_recipe_taxonomy_term_uri'; | |
} | |
/** | |
* Entity uri callback for taxonomy terms. Add special exception to redirect users away | |
* from taxonomy term pages to the associated program node page. | |
*/ | |
function content_recipe_taxonomy_term_uri($term) { | |
if ('categories' == $term->vocabulary_machine_name) { | |
return array( | |
'path' => 'recipes/' . $term->tid, | |
); | |
} else { | |
return array( | |
'path' => 'taxonomy/term/' . $term->tid, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment