Skip to content

Instantly share code, notes, and snippets.

@algotrader-dotcom
Forked from jekamozg/content_recipe.module
Created November 25, 2015 03:14
Show Gist options
  • Save algotrader-dotcom/2545b1ebb3b749b765ca to your computer and use it in GitHub Desktop.
Save algotrader-dotcom/2545b1ebb3b749b765ca 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