function hook_term_path

You are here

6 core.php hook_term_path($term)

Allows modules to provide an alternative path for the terms it manages.

For vocabularies not maintained by taxonomy.module, give the maintaining module a chance to provide a path for terms in that vocabulary.

"Not maintained by taxonomy.module" is misleading. It means that the vocabulary table contains a module name in the 'module' column. Any module may update this column and will then be called to provide an alternative path for the terms it recognizes (manages).

This hook should be used rather than hard-coding a "taxonomy/term/xxx" path.

Parameters

$term: A term object.

Return value

An internal Drupal path.

See also

taxonomy_term_path()

Related topics

2 functions implement hook_term_path()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

forum_term_path in modules/forum/forum.module
Implementation of hook_term_path().
taxonomy_term_path in modules/taxonomy/taxonomy.module
For vocabularies not maintained by taxonomy.module, give the maintaining module a chance to provide a path for terms in that vocabulary.
1 invocation of hook_term_path()
taxonomy_term_path in modules/taxonomy/taxonomy.module
For vocabularies not maintained by taxonomy.module, give the maintaining module a chance to provide a path for terms in that vocabulary.

File

developer/hooks/core.php, line 2720
These are the hooks that are invoked by the Drupal core.

Code

function hook_term_path($term) {
  return 'taxonomy/term/' . $term->tid;
}

Comments

In Drupal 7, you might want to have a look at hook_entity_info_alter(&$entity_info). For example, I have

<?php
function mmf_entity_info_alter(&$entity_info) {
 
$entity_info['taxonomy_term']['uri callback'] = 'mmf_term_uri';
}
?>

In mmf_term_uri($term), I can decide if I want to change the URI or return the default with

<?php
return taxonomy_term_uri($term);
?>