Conflict with taxonomy_defaults module
ilmaestro - October 4, 2007 - 21:54
| Project: | Content Taxonomy |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
It appears that the taxonomy field has a conflict with the taxonomy_defaults module. taxonomy_defaults automatically associates a default taxonomy with a node whenever a new node is created. It works fine, except when the content type contains a taxonomy field.
The way that taxonomy_defaults appears to work is that it overrides the nodeapi method and simply sets a default taxonomy in the $node->taxonomy. I am guessing that this is done before content taxonomy is called, which wipes out the previously set taxonomy.
I'd imagine this is a quick fix? Let me know what you find.

#1
Ok, the issue is occuring in content_taxonomy.module in the content_taxonomy_field method:
case 'submit':global $content_taxonomy_array_cleared;
if (!is_array($content_taxonomy_array_cleared) || !$content_taxonomy_array_cleared[$node->nid]) {
unset($node->taxonomy); // The problem is here!!!
$content_taxonomy_array_cleared[$node->nid] = true;
}
So what is the purpose of that bit of code? Why are we unsetting all previous taxonomy for the node?
#2
Hi,
I had the same problem and it seems to be solved like that:
Remove or comment out the unset in the function content_taxonomy_field in content_taxonomy.module:
case 'submit':global $content_taxonomy_array_cleared;
if (!is_array($content_taxonomy_array_cleared) || !$content_taxonomy_array_cleared[$node->nid]) {
#remove this: unset($node->taxonomy);
$content_taxonomy_array_cleared[$node->nid] = true;
...and change the function taxonomy_defaults_nodeapi in taxonomy_defaults.module:
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());
#change this: $taxonomy[$vid] = $vocab->multiple ? $default_tids : $default_tids[0];
#to this:
$taxonomy[$vid] = $vocab->multiple ? $default_tids : array($default_tids[0] => $default_tids[0]);
}
}
if (isset($taxonomy)) {
$node->taxonomy = $taxonomy;
}
}
}
#3
I'm having this issue as well. It would be nice to have something committed so I would be able to combine both module as I would prefer.
#4
Subscribing...
#5
subscribe
#6
I had the same issue with taxonomy terms not taking to the db post submit, and only had to change the content_taxonomy.module line 126 as per #2.
Thanks Alexh!
#7
subscribing