function _nat_update_terms in Node Auto Term [NAT] 5
Same name and namespace in other branches
- 6.2 nat.module \_nat_update_terms()
- 6 nat.module \_nat_update_terms()
- 7.2 nat.module \_nat_update_terms()
- 7 nat.module \_nat_update_terms()
Update saved node-terms.
Parameters
$terms: An array of existing NAT-term objects.
$title: Title of the node.
$body: Body of the node.
$hierarchy: The taxonomy array for the node in question. This is used to, if set, insert the new term as a child term of the selected parent.
$relations: An optional array of related terms.
$synonyms: An optional string of delimited synonyms.
1 call to _nat_update_terms()
- nat_nodeapi in ./
nat.module - Implementation of hook_nodeapi().
File
- ./
nat.module, line 623 - NAT - node auto term - is a helper module that automatically creates a term using the same title as a node.
Code
function _nat_update_terms($terms, $title, $body, $hierarchy, $relations = array(), $synonyms = NULL) {
$edit = array(
'name' => $title,
'description' => $body,
);
$edit['synonyms'] = !empty($synonyms) ? $synonyms : '';
foreach ($terms as $term) {
$edit['parent'] = isset($hierarchy[$term->vid]) ? $hierarchy[$term->vid] : array();
$edit['relations'] = count($relations) ? $relations[$term->vid] : array();
$edit['weight'] = $term->weight;
$edit['tid'] = $term->tid;
$edit['vid'] = $term->vid;
taxonomy_save_term($edit);
}
}