function content_taxonomy_autocomplete_insert_tags in Content Taxonomy 6.2
Same name and namespace in other branches
- 5 content_taxonomy_autocomplete.module \content_taxonomy_autocomplete_insert_tags()
- 6 content_taxonomy_autocomplete.module \content_taxonomy_autocomplete_insert_tags()
Insert new tags
Parameters
$nid the node id:
$terms an array of all <strong>nonexisting</strong> terms.:
Return value
an array of newly inserted term ids
1 call to content_taxonomy_autocomplete_insert_tags()
- content_taxonomy_autocomplete_form2data in ./
content_taxonomy_autocomplete.module - Helper function to transpose the values returned by submitting the content_taxonomy_autcomplete to the format to be stored in the field
File
- ./
content_taxonomy_autocomplete.module, line 384 - Defines a widget type for content_taxonomy with autocomplete
Code
function content_taxonomy_autocomplete_insert_tags($terms, $parent = NULL) {
if ($parent) {
$parent_term = taxonomy_get_term($parent);
$vid = $parent_term->vid;
}
foreach ($terms as $term) {
$edit = array(
'vid' => $term['vid'],
'name' => $term['name'],
);
if ($parent) {
$edit['parent'] = $parent;
$edit['vid'] = $vid;
}
$status = taxonomy_save_term($edit);
$saved_terms[$edit['tid']] = $edit['tid'];
}
return $saved_terms;
}