Skip to content

Instantly share code, notes, and snippets.

@jekamozg
Created July 11, 2013 14:14
Show Gist options
  • Save jekamozg/5975812 to your computer and use it in GitHub Desktop.
Save jekamozg/5975812 to your computer and use it in GitHub Desktop.
Drupal 7 taxonomy term link rewrite
/**
* 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