Skip to content

Instantly share code, notes, and snippets.

@kvnm
Last active August 29, 2015 13:56
Show Gist options
  • Save kvnm/9004502 to your computer and use it in GitHub Desktop.
Save kvnm/9004502 to your computer and use it in GitHub Desktop.
Change Drupal 7 Taxonomy term links to a custom path (leading to a custom view, page, whatever).
<?php
/**
* Implements hook_entity_info_alter().
*/
function custom_entity_info_alter(&$entity_info) {
$entity_info['taxonomy_term']['uri callback'] = 'custom_taxonomy_term_uri';
}
/**
* Redirects given vocabulary terms to a custom page.
*/
function custom_taxonomy_term_uri($term) {
switch ($term->vocabulary_machine_name) {
case 'my_vocabulary':
return array(
'path' => 'my/custom/path/' . $term->tid,
);
break;
default:
return array(
'path' => 'taxonomy/term/' . $term->tid,
);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment