| 7 path.module | path_node_update($node) |
| 8 path.module | path_node_update(Node $node) |
Implements hook_node_update().
File
- modules/
path/ path.module, line 205 - Enables users to rename URLs.
Code
function path_node_update($node) {
if (isset($node->path)) {
$path = $node->path;
$path['alias'] = trim($path['alias']);
// Delete old alias if user erased it.
if (!empty($path['pid']) && empty($path['alias'])) {
path_delete($path['pid']);
}
// Only save a non-empty alias.
if (!empty($path['alias'])) {
// Ensure fields for programmatic executions.
$path['source'] = 'node/' . $node->nid;
$path['language'] = isset($node->language) ? $node->language : LANGUAGE_NONE;
path_save($path);
}
}
}
Login or register to post comments