Last active
August 29, 2015 13:56
-
-
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).
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
<?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