function path_taxonomy_term_insert in Drupal 7
Implements hook_taxonomy_term_insert().
File
- modules/
path/ path.module, line 266 - Enables users to rename URLs.
Code
function path_taxonomy_term_insert($term) {
if (isset($term->path)) {
$path = $term->path;
$path['alias'] = trim($path['alias']);
// Only save a non-empty alias.
if (!empty($path['alias'])) {
// Ensure fields for programmatic executions.
$path['source'] = 'taxonomy/term/' . $term->tid;
// Core does not provide a way to store the term language but contrib
// modules can do it so we need to take this into account.
$langcode = entity_language('taxonomy_term', $term);
$path['language'] = !empty($langcode) ? $langcode : LANGUAGE_NONE;
path_save($path);
}
}
}