function hashtags_enable in Hashtags 7.2
Same name and namespace in other branches
- 6.2 hashtags.install \hashtags_enable()
- 6 hashtags.install \hashtags_enable()
- 7 hashtags.install \hashtags_enable()
@file Install, update and uninstall functions for the hashtags module.
File
- ./
hashtags.install, line 7 - Install, update and uninstall functions for the hashtags module.
Code
function hashtags_enable() {
$vocabulary = taxonomy_vocabulary_load(variable_get('hashtags_vocabulary', 0));
if (!$vocabulary) {
$edit = array(
'name' => t('Hashtags'),
'machine_name' => 'hashtags',
'description' => t('Hashtag vocabulary'),
'hierarchy' => 1,
'module' => 'hashtags',
'weight' => -11,
);
$vocabulary = (object) $edit;
taxonomy_vocabulary_save($vocabulary);
variable_set('hashtags_vocabulary', $vocabulary->vid);
}
$field_name = 'field_' . $vocabulary->machine_name;
if (!field_info_field($field_name)) {
$field = array(
'field_name' => $field_name,
'type' => 'taxonomy_term_reference',
// Set cardinality to unlimited for tagging.
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
'vocabulary' => $vocabulary->machine_name,
'parent' => 0,
),
),
),
);
field_create_field($field);
variable_set('hashtags_terms_field', $field_name);
}
}