function path_taxonomy_term_insert

path_taxonomy_term_insert($term)

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);
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!path!path.module/function/path_taxonomy_term_insert/7.x