function pathauto_nodeapi in Pathauto 5.2
Same name and namespace in other branches
- 5 pathauto_node.inc \pathauto_nodeapi()
- 6.2 pathauto.module \pathauto_nodeapi()
- 6 pathauto.module \pathauto_nodeapi()
Implementation of hook_nodeapi().
File
- ./
pathauto.module, line 217 - Main file for the Pathauto module, which automatically generates aliases for content.
Code
function pathauto_nodeapi(&$node, $op, $teaser, $page) {
if (module_exists('path')) {
switch ($op) {
case 'insert':
case 'update':
_pathauto_include();
// Get the specific pattern or the default
$pattern = trim(variable_get('pathauto_node_' . $node->type . '_pattern', FALSE));
if (!$pattern) {
$pattern = trim(variable_get('pathauto_node_pattern', FALSE));
}
// Only do work if there's a pattern
if ($pattern) {
// Only create an alias if the checkbox was not provided or if the checkbox was provided and is checked
if (!isset($node->pathauto_perform_alias) || $node->pathauto_perform_alias) {
$placeholders = pathauto_get_placeholders('node', $node);
$src = "node/{$node->nid}";
$alias = pathauto_create_alias('node', $op, $placeholders, $src, $node->nid, $node->type);
}
}
break;
case 'delete':
path_set_alias('node/' . $node->nid);
path_set_alias('node/' . $node->nid . '/feed');
break;
default:
break;
}
}
}