function nodesymlinks_item_alias_save in NodeSymlinks 7
Same name and namespace in other branches
- 6 nodesymlinks.inc \nodesymlinks_item_alias_save()
Create alias for duplicate menulink if original node.
1 call to nodesymlinks_item_alias_save()
- nodesymlinks_item_save in ./
nodesymlinks.inc - Save item to database.
File
- ./
nodesymlinks.inc, line 604 - Main NodeSymlinks callbacks
Code
function nodesymlinks_item_alias_save(&$item, &$node) {
// TODO: refactor this.
// Integrate with Path.
if (module_exists('path')) {
// We need to know pid to provide "update" otherwise
// Path creates new alias to the same path.
$pid = !empty($item['alias']['pid']) ? $item['alias']['pid'] : NULL;
// Integrate with Pathauto.
if (module_exists('pathauto')) {
// Pathauto alias.
if (!empty($item['alias']['pathauto']) || empty($item['alias']['path'])) {
$op = $item['is_new'] ? 'insert' : 'update';
return nodesymlinks_pathauto_create_alias($item, $node, $op);
}
else {
$path = array(
'source' => $item['link_path'],
'alias' => $item['alias']['path'],
'pid' => $pid,
'language' => $node->language,
);
return path_save($path);
}
}
elseif (!empty($item['alias']['path'])) {
// Save custom path alias.
$path = array(
'source' => $item['link_path'],
'alias' => trim($item['alias']['path']),
'pid' => $pid,
'language' => $node->language,
);
return path_save($path);
}
else {
// Create and save default alias based on node path.
$path_alias = empty($node->path) || $node->path == 'node/' . $node->nid ? '' : $node->path . '_' . $item['mlid'];
$path = array(
'source' => $item['link_path'],
'alias' => $path_alias,
'pid' => $pid,
'language' => $node->language,
);
return path_save($path);
}
}
}