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.
the module itslf has a part where it checks for changes so you can not resave all nodes with VBO and so set the lineage
i excluded this code part for the update
// Are there changes?
asort($tidsnew);
asort($tidsold);
//if (count(array_diff($tidsnew, $tidsold)) > 0 || count(array_diff($tidsold, $tidsnew)) > 0) {
// This field and language have changed tids, we need to select parents.
foreach ($language as $term) {
// Get full ancestry of term... carefull, it includes our term also.
$parent_term_objects = taxonomy_get_parents_all($term['tid']);
if (count($parent_term_objects) > 1) {
foreach ($parent_term_objects as $parent) {
// Filter out ourselves, terms added as parents of other terms and
// terms already selected during save ($tidsnew).
if ($term['tid'] !== $parent->tid && !in_array($parent->tid, $tidsnew)) {
$entity->{$tax_field_name}[$lang_code][] = array('tid' => $parent->tid);
$tidsnew[] = $parent->tid;
}
}
}
}
//}
maybe there could be a setting for that. especially for non coders.
btw. i love this module.
having no linage makes really big problems with facetapi and taxonomy filtering.
Comment | File | Size | Author |
---|---|---|---|
#9 | updating_existing_fields-2288295-9.patch | 8.89 KB | Nikolay Shapovalov |
Comments
Comment #1
yareckon CreditAttribution: yareckon commentedmarcoka, maybe we can write a vbo action that forces TSL to set lineage on an entity. I am pretty loathe to allow folks to turn off the change checking generally, because it is an expensive operation to load every term back up the chain for every language in a deep heirarchy. It's not that big of a deal, because we do this only at save time, and most sites have many more reads than writes, but it's still good to not do any uneeded work.
Comment #2
PlayfulWolf CreditAttribution: PlayfulWolf commentedI think both ways: either button on module options to "Rebuild currently used terms with lineage" or VBO is ok. Btw, great module, really lifesaver for all of us coming from HS module...
Comment #3
Breakerandi CreditAttribution: Breakerandi commentedHi! I am a non coder and would love this feature!
Can anybody explain me if there is a quick solution now for me?
Drush integration would also be awesome!
Comment #4
Summit CreditAttribution: Summit commentedHi,
Yes please for updating existing fields.
I come from the HS situation that I had in D6 a field with "saving only deepest term"
I migrated everything to D7, and would love to be able to use "term lineage".
It would be great if I could update my node-term relation so all parent terms are also attached to the nodes.
Does this module work together with HS?
I see this issue https://www.drupal.org/node/2390295#comment-9428209
There is stated "the module only actively searches for and sets hierarchy when a field is changed. This should actually be enough though".
I do not think this is enough. With node save, if the term is not changed, it should set the hierarchy I think.
I also see this solution: http://blog.yawd.eu/2011/how-automatically-add-taxonomy-relations-drupal-7/
And of course it would be great to have a VBO action with this!
greetings, Martijn
Comment #5
marcoka CreditAttribution: marcoka commentedi posted what i did
-removed the code fro mabove from the module
-run vbo update on nodes
-put code back in (because hacking modules sucks for updates)
Comment #6
Summit CreditAttribution: Summit commentedOk!, I will test this tomorrow (having non-drupal daytime job:)
Thanks for posting. Do I need to use a special VBO action for this?
Thanks for your quick reply and greetings, Martijn
Comment #7
marcoka CreditAttribution: marcoka commentedyou just create an action through the interface that updates selected nodes.
Comment #8
Summit CreditAttribution: Summit commentedHi Marcoka, which field do I have to select for the update? It seems there is no VBO action on Drupal 7 without changing something on a node?
EDIT: I just selected publish nodes...and I think it worked!
greetings, Martijn
Comment #9
Nikolay ShapovalovI fully rewrite save algorithm and add setting to force find parents each time entity is update.
Now we keep input user data without changes, and push parents terms to the end of field values.
If user had manually select parent, we won't put it again. But user can insert as many duplicates of term as he want.
Also if we try to save more values then it is possible for field, error message displays.
So if you want to use it with VBO
1) Apply patch.
2) Go settings admin/structure/taxonomy/taxonomy_set_lineage and select Force rewrite
3) Run VBO.
Comment #10
BBCThanks for the patch! I just ran into a case where I had imported about 900 nodes via feeds. The patch plus VBO solution worked like a charm.
Comment #11
akoepke CreditAttribution: akoepke at Business News commentedI don't think forcing it to happen each time an entity is saved is a good idea.
What I have in mind is adding an action to the module which will allow you to force an update of the lineage for all entities.
This means you can force an update to happen but doesn't change the default behaviour of the module.
Comment #12
akoepke CreditAttribution: akoepke at Business News commentedThis has been resolved by adding a Node operation. From the content screen you can now select "Update Taxonomy Term Parents" which will update the linage for those nodes without you having to edit and change the terms.
Comment #13
akoepke CreditAttribution: akoepke at Business News commentedI have just added the same functionality to the Drupal 9 version, 2.0.0-rc1 is now available.