The function content_taxonomy_terms_by_field currently returns all taxonomy terms for a given node regardless what $vid (vocabulary id) you send it. So, when content_taxonomy_field calls content_taxonomy_terms_by_field for each content taxonomy field you have defined on a page, each field will be filled with all taxonomy terms. This, I believe, is not the intended behavior.
To stop the entire taxonomy from printing for each content taxonomy field:
edit content_taxonomy.module
in function content_taxonomy_terms_by_field, around line 214,
replace:
$result = db_query("SELECT n.tid FROM {term_hierarchy} h, {term_node} n WHERE
n.nid = %d AND n.tid = h.tid AND h.parent = %d", $node->nid, $parent);
while ($data = db_fetch_array($result)) {
$term = taxonomy_get_term($data["tid"]);
$additions[$term->tid] = $term;
}
return $additions;
with:
$result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {term_data} t
INNER JOIN {term_hierarchy} h ON t.tid = h.tid
INNER JOIN {term_node} r ON r.tid = t.tid
WHERE t.vid = %d AND r.nid = %d AND h.parent = %d
ORDER BY weight', 't', 'tid'), $vid, $node->nid, $parent);
$terms = array();
while ($term = db_fetch_object($result)) {
$terms[$term->tid] = $term;
}
return $terms;
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | content_taxonomy.patch | 838 bytes | David Lesieur |
Comments
Comment #1
Axmodeux commentedI will follow this thread because, I think I meet the same problem.
I don't search enough to be sure that is not my fault ^^'
Comment #2
wojtha commentedI have had the same problem and this patch works for me.
Thanks dmarble!
Comment #3
dmarble commentedI was on the clock at work, so it was my pleasure!
Comment #4
leeksoup commentedThanks dmarble!
I just updated to latest version for a fix to the critical bug reported at http://drupal.org/node/121242
But as soon as I did that and edited & saved a node, its CT fields would get hosed. Randomly populated with tids belonging to other vocabs, breaking my site. This fixes it.
CT owner, please roll this or equivalent patch into main codestream.
Comment #5
Anonymous (not verified) commentedI have this problem too. The patch didn't work for me. I still see all terms in both displays.
Comment #6
ilmaestro commentedFor what it's worth, I had this problem to and the patch worked. Hopefully it gets commited.
Comment #7
yeeloon commenteddmarble u rock!
i've been searching high n low for the solution, finally i came across your solution!
Yup, hopefully it gets committed.
Comment #8
pgrunzjr commenteddmarble,
Thank you very much for this. I knew something wasn't right but don't yet have knowledge enough of drupal's inner workings to fix it myself. Worked like a charm. Hope this gets committed.
Comment #9
Anonymous (not verified) commentedAbove patch solved my similar issues.
Comment #10
David Lesieur commentedThe attached patch shows how I solved it.
The field's vocabulary was never taken into account because the condition
is_numeric($parent)inif (is_numeric($parent) && $depth == 1)was always true. When no term is specified for the field, $parent is zero... and zero is numeric. Thus, theelseblock was never visited in my case, and it is that block that selects terms within the field's designated vocabulary.Comment #11
flndr commentedNeither the original suggestion or the patch submitted by David is working for me.
Comment #12
leeksoup commentedLatest version of CT does not have the original problem reported on this bug - at least it works for me.
Comment #13
blinko commentedI used the latest version of Drupal & CT but I had still this problem... So I applied the patch as described above and it solved the bug for me!... Thanks :-)
But why isn't that patch dated AUG 07, included in the latest version dated JAN 08... (?!)
Comment #14
fde commentedWas burned by the same bug today.
Good for me that I found this thread, after some hours trying to understand if I was doing something wrong...
The fix from dmarble solved the issue. Would be good to integrate it in the last development version.
Comment #15
summit commentedSubscribing, greetings, Martijn
Comment #16
bcn commentedPatch from #10 works for me... Thanks
Comment #17
csc4 commentedThe patch at http://drupal.org/node/210824 fixed this for me.
Comment #18
bjacob commentedFor me patch supplied in #10 solved the problem. It's import to edit and submit the node again. Thanks a lot!
Comment #19
magnus commentedCleanup of old issues. According to maintainer: "active development is only done for the 6.x branch! 5.x is not supported any more".
Open a new issue if problem still exist.