function auto_nodetitle_set_title in Automatic Nodetitles 7
Same name and namespace in other branches
- 8 auto_nodetitle.module \auto_nodetitle_set_title()
- 5 auto_nodetitle.module \auto_nodetitle_set_title()
- 6 auto_nodetitle.module \auto_nodetitle_set_title()
Sets the automatically generated nodetitle for the node.
3 calls to auto_nodetitle_set_title()
- auto_nodetitle_node_presave in ./
auto_nodetitle.module - Implements hook_node_presave().
- auto_nodetitle_operations_update in ./
auto_nodetitle.module - Callback function for updating node titles.
- _auto_nodetitle_save_title in ./
auto_nodetitle.module - Helper function to save node title.
File
- ./
auto_nodetitle.module, line 123 - Allows hiding of the node title field and automatic title creation.
Code
function auto_nodetitle_set_title(&$node) {
$types = node_type_get_types();
$pattern = variable_get('ant_pattern_' . $node->type, '');
if (trim($pattern)) {
$node->changed = REQUEST_TIME;
$node->title = _auto_nodetitle_patternprocessor($pattern, $node);
}
elseif (!empty($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,
));
}
// Allow other modules to alter node title.
drupal_alter('auto_nodetitle', $node);
// Ensure the generated title isn't too long.
$node->title = truncate_utf8($node->title, 70, TRUE, TRUE);
// With that flag we ensure we don't apply the title two times to the same
// node. See auto_nodetitle_is_needed().
$node->auto_nodetitle_applied = TRUE;
}