You are here

function path_node_insert in Drupal 7

Implements hook_node_insert().

1 call to path_node_insert()
path_node_update in modules/path/path.module
Implements hook_node_update().

File

modules/path/path.module, line 187
Enables users to rename URLs.

Code

function path_node_insert($node) {
  if (isset($node->path) && isset($node->path['alias'])) {
    $path = $node->path;
    $path['alias'] = trim($path['alias']);

    // Only save a non-empty alias.
    if (!empty($path['alias'])) {

      // Ensure fields for programmatic executions.
      $langcode = entity_language('node', $node);
      $path['source'] = 'node/' . $node->nid;
      $path['language'] = isset($langcode) ? $langcode : LANGUAGE_NONE;
      path_save($path);
    }
  }
}