function taxonomy_defaults_nodeapi in Taxonomy Defaults 5
Adds selected default terms from non-active vocabularies to newly created nodes
File
- ./
taxonomy_defaults.module, line 52 - Taxonomy defaults - allows assignment of default terms to node types, either
Code
function taxonomy_defaults_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
if ($op == 'submit') {
$taxonomy = $node->taxonomy;
$type_vocabularies = taxonomy_get_vocabularies($node->type);
foreach (taxonomy_get_vocabularies() as $vid => $vocab) {
$activevocab = array_key_exists($vid, $type_vocabularies);
// Active vocabs have been inserted via the form already and may have been modified by the user
if (!$activevocab && variable_get("taxdef_{$node->type}_{$vid}_active", FALSE)) {
$default_tids = variable_get("taxdef_{$node->type}_{$vid}", array());
$taxonomy[$vid] = $vocab->multiple ? $default_tids : $default_tids[0];
}
}
if (isset($taxonomy)) {
$node->taxonomy = $taxonomy;
}
}
}