function _media_browser_plus_ensure_field_tags in Media Browser Plus 7
Same name and namespace in other branches
- 7.2 media_browser_plus.install \_media_browser_plus_ensure_field_tags()
Make sure the field_tags field exists and is of the right type.
1 call to _media_browser_plus_ensure_field_tags()
- media_browser_plus_install in ./
media_browser_plus.install - Implements hook_install().
File
- ./
media_browser_plus.install, line 20 - Install file for media_browser_plus.
Code
function _media_browser_plus_ensure_field_tags() {
$t = get_t();
// Make sure the 'tags' vocabulary exists.
$vocabulary = taxonomy_vocabulary_machine_name_load('tags');
if (!$vocabulary) {
$description = st('Use tags to group articles on similar topics into categories.');
$help = st('Enter a comma-separated list of words to describe your content.');
$vocabulary = (object) array(
'name' => 'Tags',
'description' => $description,
'machine_name' => 'tags',
'help' => $help,
);
taxonomy_vocabulary_save($vocabulary);
}
$field = array(
'field_name' => 'field_tags',
'type' => 'taxonomy_term_reference',
// Set cardinality to unlimited for tagging.
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'entity_type' => 'file',
'label' => 'Tags',
'widget' => array(
'type' => 'taxonomy_autocomplete',
),
'settings' => array(
'allowed_values' => array(
array(
'vocabulary' => $vocabulary->machine_name,
'parent' => 0,
),
),
),
);
_media_browser_plus_ensure_field($field);
// Ensure instance for each media bundle.
foreach (array_keys(media_type_get_types()) as $bundle) {
$field['bundle'] = $bundle;
_media_browser_plus_ensure_instance($field);
}
}