function auto_nodetitle_set_title in Automatic Nodetitles 5
Same name and namespace in other branches
- 8 auto_nodetitle.module \auto_nodetitle_set_title()
- 6 auto_nodetitle.module \auto_nodetitle_set_title()
- 7 auto_nodetitle.module \auto_nodetitle_set_title()
2 calls to auto_nodetitle_set_title()
- auto_nodetitle_nodeapi in ./
auto_nodetitle.module - Implementation of hook_nodeapi().
- auto_nodetitle_operations_update in ./
auto_nodetitle.module - Callback function for updating node titles.
File
- ./
auto_nodetitle.module, line 69 - Allows hiding of the node title field and automatic title creation
Code
function auto_nodetitle_set_title(&$node) {
$types = node_get_types();
$pattern = variable_get('ant_pattern_' . $node->type, '');
if (trim($pattern)) {
$node->changed = time();
$node->title = _auto_nodetitle_patternprocessor($pattern, $node);
}
else {
if ($node->nid) {
$node->title = t('@type @node-id', array(
'@type' => $types[$node->type]->name,
'@node-id' => $node->nid,
));
}
else {
$node->title = t('@type', array(
'@type' => $types[$node->type]->name,
));
}
}
// Ensure the generated title isn't too long.
$node->title = substr($node->title, 0, 255);
// With that flag we ensure we don't apply the title two times to the same node.
$node->auto_nodetitle_applied = TRUE;
}