function document_install in Document 7
Same name and namespace in other branches
- 6 document.install \document_install()
- 8.x document.install \document_install()
File
- ./
document.install, line 7
Code
function document_install() {
// use get_t() to get the name of our localization function for translation
// during install, when t() is not available.
$t = get_t();
//Create a vocabulary for documents.
document_get_vocid();
// Ensure the node type is available.
node_types_rebuild();
$types = node_type_get_types();
node_add_body_field($types['document'], 'Abstract');
$vocab = document_get_vocab();
//Create document type field.
$field = array(
'field_name' => 'document_types',
'type' => 'taxonomy_term_reference',
'settings' => array(
'allowed_values' => array(
array(
'vocabulary' => $vocab->machine_name,
'parent' => 0,
),
),
),
);
field_create_field($field);
$instance = array(
'field_name' => 'document_types',
'entity_type' => 'node',
'label' => $t('Document type(s)'),
'bundle' => 'document',
'required' => true,
'widget' => array(
'type' => 'options_select',
),
'display' => array(
'default' => array(
'type' => 'hidden',
),
'teaser' => array(
'type' => 'hidden',
),
),
);
field_create_instance($instance);
}