Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If "Save values additionally to the core taxonomy system" is checked, have the field check the Taxonomy system to see if it was changed, when the node is saved/edited.
or
Make a Bulk Operations to update/change taxonomy in bulk.
Comment | File | Size | Author |
---|---|---|---|
#46 | content_tax.patch | 1.32 KB | pwaterz |
Comments
Comment #1
mikeytown2 CreditAttribution: mikeytown2 commentedCheck the database term_node table, see what CCK fields need to be updated? Do a comparison, assuming that the term_* table is always correct, making the various changes to CCK's fields.
Comment #2
Flying Drupalist CreditAttribution: Flying Drupalist commentedsubscribe
Comment #3
Flying Drupalist CreditAttribution: Flying Drupalist commentedContent Taxonomy needs to sync with taxonomy. The way that all current terms are lost is not good.
Comment #4
thekevinday CreditAttribution: thekevinday commentedI have been poking around at this problem myself.
It looks like there is something wrong with the content_taxonomy_field function.
The follow hack+patch causes everything to work, but I have doubts as to whether this is a correct fix:
Notice that all I did was comment out the
if ($field['save_term_node']) {
if statement.Comment #5
Flying Drupalist CreditAttribution: Flying Drupalist commentedWhat's the expected behavior after making this change?
On my node/edit page the vocabulary loses all other terms except for the one added in CT. On the node view page however all terms are present, CT/and regular taxonomy term.
Comment #6
thekevinday CreditAttribution: thekevinday commentedPrior to this hack:
I have multiselect (http://drupal.org/project/multiselect) used as a cck content taxonomy field.
I do not use the original taxonomy fields themselves as they multiblock+content taxonomy+cck is being used to provide a more user-friendly way of assigning taxonomies from a select list.
The problem I noticed is that while the changes I made to this cck field did properly save for the cck field itself, the taxonomy vocabulary itself never registered that these taxonomies were being applied.
So at this point in time, the taxonomy cck field never synced up with the actual taxonomy.
That is to say, no matter what I selected with the cck taxonomy field, the term_node table would never populate with data.
I looked at the taxonomy database tables (if I remember correctly, I think it is the term_node table) and there was no node to taxonomy associations going on despite what the cck taxonomy field was claiming.
With this hack:
When I selected the appropriate taxonomies from the select list and saved, the term_node table now populated with data and the taxonomy core was now synced with what the cck taxonomy fields claim.
Comment #7
Tom Ash CreditAttribution: Tom Ash commentedWhy was the the if ($field['save_term_node']) { statement there in the first place? I presume someone'd need to check whether removing it does any harm before merging it into module?
Comment #8
Tom Ash CreditAttribution: Tom Ash commentedHang on, it seems the if statement just check whether 'Save values additionally to the core taxonomy system (into the 'term_node' table).' is checked at the 'Configure' page for your Content Taxonomy field - I located this by searching for $field['save_term_node'] in the module code. It works for me when I check that box - it'd be nice to be able to have it checked by default but that's another issue.
Comment #9
mikeytown2 CreditAttribution: mikeytown2 commented@Thomas Ash
This is not a UI issue, like your describing. Change a nodes taxonomy via Views Bulk Operation. That change doesn't cross over to the CCK taxonomy field; thus it gets displayed wrong. Other modules change the taxonomy as well, so Content Taxonomy has to detect the change if it happened, and act accordingly.
Comment #10
Tom Ash CreditAttribution: Tom Ash commentedOK, good point, I'd forgotten your original issue description. Could you clarify the first half of that description?
Comment #11
thekevinday CreditAttribution: thekevinday commentedI apologize, it seems I was so busy thinking about the syncing issue that I misread this thread.
My problem was apparently that I overlooked "Save values additionally to the core taxonomy system" setting somewhere.
Sorry for almost hijacking this thread.
Comment #12
Flying Drupalist CreditAttribution: Flying Drupalist commentedI'm not sure if I still want it synched, but I definitely need a way to upgrade from core tax to CT.
My nodes all have lots of terms on them, I can't imagine losing them all in an upgrade.
Comment #13
anrikun CreditAttribution: anrikun commented+1 Subscribe
Yes it have to be synched
or make a Bulk operation to update content taxonomy
Comment #14
mrfelton CreditAttribution: mrfelton commented+1. subscribing
Comment #15
Bilmar CreditAttribution: Bilmar commentedsubscribing
Comment #16
portulacasubscribing
Comment #17
phpepe CreditAttribution: phpepe commentedsubscribing
Comment #18
pierre_cotiniere CreditAttribution: pierre_cotiniere commentedsubscribing
Comment #19
pierre_cotiniere CreditAttribution: pierre_cotiniere commentedI found this php script which can help : http://drupal.org/node/485328#comment-1952462
Comment #20
xjmTracking.
Comment #21
Summit CreditAttribution: Summit commentedSubscribing, greetings, Martijn
Comment #22
yan CreditAttribution: yan commentedThese are related issues:
#332454: Also operate as taxonomy widget ONLY
#794068: Sync with core (duplicate of this issue)
Comment #23
yan CreditAttribution: yan commentedAre the maintainers ever gonna comment on this issue? It's been more than a year now that it exists.
Comment #24
rjbrown99 CreditAttribution: rjbrown99 commentedI'm on 6.x-1.0-rc2 and have been struggling with this all day. Specifically, what I wanted to do was to load up a node, modify a content_taxonomy field, and the save the node. We're talking specifically about updates to existing nodes and not newly created nodes. This is important.
Here's where I started. Load up the node and clear out both the node cache and CCK cache.
Pretty straight-forward. Although what ends up happening in this case is that the core taxonomy in term_node is updated, but the CCK field is not. I confirmed this by reviewing both term_node and content_type_mytype (field_myfield_value). I can see 15976 in the term_node but the old TID in field_myfield_value. If I insert a dsm($fullnode) in front of the node_save and after the node_save, it does properly show 15976 as the term for that field. So I know it's getting set properly, but node_save isn't registering it upon save.
Note that this DOES work if I manually click edit on the node and then save the changes. Both the CCK field and term_node tables are updated properly.
I have spent far too long trying to figure out why that happens, so I gave up and hacked it. After my node_save I manually update the DB.
Here are issues that are potentially related:
#594004: taxonomy_node_get_terms() needs a $reset param that node_load can call when *it* is reset
#217824: Content Taxonomy is not saved when "cck" or "both" are specified
#531274: Using node_save with a Content Taxonomy Field
Here's where I found about clearing CCK cache:
#605594: node_load() during signup's node_save() breaks node data cached by CCK
I have no idea where to go from here. Suggestions would be more than welcome.
Comment #25
meatbag CreditAttribution: meatbag commentedsubscribing
Comment #26
jvieille CreditAttribution: jvieille commentedContent taxonomy is irrelevant as long as it does not sync with core taxonomy.
This is an addon, which should not be allowed to expose an incompatible implementation of an existing feature.
Comment #27
yan CreditAttribution: yan commentedWell, I think there are cases that don't need content taxonomy to be synced with core taxonomy. For example using the module as a sort of "taxonomy reference" (just like "user reference" or "node reference") if you want to connect a node with a taxonomy term without actually assigning it to the term.
But I totally agree that it is a problem to somehow duplicate a core functionality without allowing to use the core version or at least get both versions synced.
It seems to me that the Content Taxonomy maintainers are suffering a work overload or something like that. The issue queue is really long and even critical issues aren't addressed sometimes -- like this one.
Comment #28
Summit CreditAttribution: Summit commentedHi, in reply to #24
I think that you also need content_update, see: http://www.balancedscale.com/blog/201006/update-cck-fields-custom-drupal...
greetings, Martijn
Comment #29
Steven Jones CreditAttribution: Steven Jones commentedSo I guess the approach would be thus:
This is probably fairly simple, but still fraught with intricacies,
Comment #30
yan CreditAttribution: yan commentedI'm wondering if it is really necessary to duplicate the taxonomy data in the content taxonomy table. At least there should be an option to simply use the 'real' taxonomy data. That way, no synchronization is necessary.
Then there are other cases where we might want to 'reference' a node to a taxonomy term without actually adding the term to it. In that case we could save the data in the content taxonomy table only.
Comment #31
Steven Jones CreditAttribution: Steven Jones commentedIf you don't store the data in the CCK tables, then you just end up with the opposite problem: things that are supposed to work with CCK fields won't when they get the data from the tables directly.
Comment #32
jvieille CreditAttribution: jvieille commentedWhat is the reason for storing the taxonomy terms associated to nodes through CCK in different tables than core's?
Comment #33
Steven Jones CreditAttribution: Steven Jones commentedViews.
Comment #34
YK85 CreditAttribution: YK85 commentedDoesn't Views support taxonomy fields?
Comment #35
Steven Jones CreditAttribution: Steven Jones commentedOkay, I was being a bit pedantic. But it is very useful having the values in CCK's tables.
Comment #36
xjm#32, #34: because CCK lets you do things that core taxonomy in D6 does not support. For example, suppose I have a "University" vocabulary. I might want to let someone add their undergraduate school(s), their graduate school(s), their medical school in separate fields on a profile. I want to preserve the information that one is the undergrad, another the grad, etc., but I want to use the one main vocab of schools. That's a use case that core taxonomy in D6 does not address. (D7 will).
Comment #37
jvieille CreditAttribution: jvieille commentedThat just being able to lay down several fields for the same vocabulary.
Basically, that does not change much about the core capability of
- defining the vocabularies associated to a type of node
- associating multiple terms of each vocabulary to a specific node
the main difference is that CCK allows to put these terms "in context"
A - breaking - consequence is that CCK allows the same term to possibly appear more than once for different context/meaning in the same node.
The best handling of this improvement would be to deal with the context (field definition) in the CCK tables, and extend the core table appropriately, not duplicating the taxonomy system.
Is that forbidden?
Comment #38
xjm#37: Alter a core table structure? Forbidden? Perhaps not. Unwise? Definitely.
This is a CCK module. The whole point of it existing at all is that it exposes taxonomy to all the flexibility of CCK. Therefore, it stores its data using CCK's API, which means CCK's types of tables.
Also, the current codebase for the module is end-of-lifed, since (as I mention) taxonomy has been completely redesigned in D7 and core includes the functionality of taxonomy term reference fields in the new Field API. So, I don't think there's much point in arguing against the fundamental architecture (and existence?) of a module that's existed for 3.5 years and is in the top 100 most used contrib modules available on d.o. If you think it's a bad idea, then don't use it.
Comment #39
TrevorBradley CreditAttribution: TrevorBradley commentedEDIT: Deleted my comment.. I can verify the following works to update a CCK Taxonomy Field:
$node ->my_cck_taxonomy_field[]['value'] = 123;
Where 123 is a Taxonomy tid associated with the correct vocabulary.
(I'm working on a simpler problem, updating simply a CCK Taxonomy field without worrying about the node taxonomy.)
Comment #40
jean84 CreditAttribution: jean84 commentedhello seems i have the same problem (maybe)
i have "Save values additionally to the core taxonomy system" activated, but when i try to use the module to add a taxonomie term the new term is assigned to the node but taxonomie dont display it.
So my question is is there a working fix now and please explain exactly how to do it because i am not a coder i dont know where to put a line to change....
Comment #41
thebuckst0p CreditAttribution: thebuckst0p commentedSubscribe. Working on a huge migration now and need to sync automatically migrated term_node links to content_taxonomy fields... I'll have to code something custom but it would be nice if the module didn't duplicate the data.
Comment #42
thebuckst0p CreditAttribution: thebuckst0p commentedI solved this with a Drush migration script, documented here: Re-Sync Content Taxonomy from core taxonomy.
Comment #43
pwaterz CreditAttribution: pwaterz commentedreplace the function content_taxonomy_options_widget in content_taxonomy_options.module with the following code.
<?/**
* Implementation of hook_widget().
*/
function content_taxonomy_options_widget(&$form, &$form_state, $field, $items, $delta = NULL) {
/**
* This fixes the problem if you add content taxonomy after you have been using normal taxonomy.
* This fix will load in the old terms on the node and make them selected. So when the node is saved again they don't loose the old terms.
*/
if($field['save_term_node'] == 1){
if(!$items[0]['value']){
if($form['nid']['#value']){
$node = new stdClass();
$node->vid = $form['vid']['#value'];
$node_terms = taxonomy_node_get_terms($node);
$items = array();
foreach($node_terms as $term){
if($field['vid'] == $term->vid){
$items[]['value'] = $term->tid;
}
}
}
}
}
$element = array(
'#type' => ($field['widget']['type'] == 'content_taxonomy_select') ? 'optionwidgets_select' : 'optionwidgets_buttons',
'#default_value' => !empty($items) ? $items : array(),
);
return $element;
}?>
Comment #44
pwaterz CreditAttribution: pwaterz commentedreplace the function content_taxonomy_options_widget in content_taxonomy_options.module with the following code.
Comment #45
kartik.gmf CreditAttribution: kartik.gmf commentedIn my setup the taxonomies and the CCK's are synced but the issue is that the parents are not.
My taxonomies are defined like this
Parent A
- Child A1
- Child A2
- Child A3
Parent B
- Child B1
- Child B2
My content type has fields which use this taxonomy. When I select Child A1 in a CCK field it is added to the term_node table, but Parent A is not.
I need Parent A also to be associated in the term_node table since I need to use the Faceted Search module which drills down content based on various facets.
Please help !
Comment #46
pwaterz CreditAttribution: pwaterz commentedHere is a patch from my code above.
Comment #47
djroshi CreditAttribution: djroshi commentedMy approach to syncing core taxonomy and content taxonomy fields within a node is to implement hook_content_fieldapi() within content_taxonomy.module, to update all nodes of a certain content type when the content taxonomy field settings are updated, specifically when the vocabulary setting for the field is changed:
This is only a partial solution to the issue, however it seems to suit my current use case - migrating core taxonomy to content taxonomy fields for existing nodes. I will update this thread if I discover any issues with this while I carry out the migration.
Comment #48
crcarlin CreditAttribution: crcarlin commentedSubscribe.
image import can set taxonomy terms, but it does so in the system table, getting everything out of sync.
Comment #49
pwaterz CreditAttribution: pwaterz commentedJust as an FYI this module is not longer maintained.