node_type_set_defaults
- Versions
- 7
node_type_set_defaults($info = array())
Set the default values for a node type.
The defaults are for a type defined through hook_node_info(). When populating a custom node type $info should have the 'custom' key set to 1.
Parameters
$info An object or array containing values to override the defaults.
Return value
A node type object.
Code
modules/node/node.module, line 745
<?php
function node_type_set_defaults($info = array()) {
static $type;
if (!isset($type)) {
$type = new stdClass();
$type->type = '';
$type->name = '';
$type->base = '';
$type->description = '';
$type->help = '';
$type->has_title = 1;
$type->has_body = 1;
$type->title_label = t('Title');
$type->body_label = t('Body');
$type->custom = 0;
$type->modified = 0;
$type->locked = 1;
$type->is_new = 1;
}
$new_type = clone $type;
$info = (array) $info;
foreach ($info as $key => $data) {
$new_type->$key = $data;
}
// If the type has no title or body, set an empty label.
if (!$new_type->has_title) {
$new_type->title_label = '';
}
if (!$new_type->has_body) {
$new_type->body_label = '';
}
$new_type->orig_type = isset($info['type']) ? $info['type'] : '';
return $new_type;
}
?>Login or register to post comments 