function path_taxonomy_term_insert

Implements hook_taxonomy_term_insert().

File

modules/path/path.module, line 266

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.