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.
Here is the code for my computed field:
$node_field[0]['value'] = $node->taxonomy[tags][7] ." ". $node->title;
So in the end my field should look like this: [taxonomy term] [title]
This field updated correctly if I edit the node and then re-save it. Upon using your module on 57,000+ nodes, each one shows up as just [title]. So it actually did compute the field (otherwise it would be blank), it just computed it incorrectly and didn't pull the taxonomy for some reason. Trying again resulted in 57,000 "duplicate entry" errors.
Comment | File | Size | Author |
---|---|---|---|
LiveTechnician.png | 15.44 KB | LiveTechnician22 | |
LiveTechnician.png | 15.44 KB | LiveTechnician22 |
Comments
Comment #1
frakke CreditAttribution: frakke commentedThe taxonomy handling is a bit tricky. When editing nodes, the taxonomy is in one format, and when re-computing it is in a different format. The code below should do the trick. It might not fit your needs excactly, bu it should give you the basic idea :)
Comment #2
frakke CreditAttribution: frakke commentedFrom the README.txt:
"Please note that when you re-compute the nodes, the node is fetched through node_load() which means that the format of some values might defer from when you submit the node through the node edit form. $node->taxonomy does this."
This is not a bug. This is just the way is has to be. The alternative would be, that I had to emulate a node submit which would in my opinion be a rather more messy solution with many potential pitfalls.
Comment #4
dervishmoose CreditAttribution: dervishmoose commentedAnother work around is to not use the use $node->taxonomy but to get the terms via taxonomy_node_get_terms in the computed field. This will work in both the edit form and in re-compute and in a views bulk operation.
edit: oops, I see this code will only work in D6. However, I think something similar can be done in D7.