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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yareckon’s picture

marcoka, 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.

PlayfulWolf’s picture

I 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...

Breakerandi’s picture

Hi! 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!

Summit’s picture

Hi,
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

marcoka’s picture

i 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)

Summit’s picture

Ok!, 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

marcoka’s picture

you just create an action through the interface that updates selected nodes.

Summit’s picture

Hi 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

Nikolay Shapovalov’s picture

Status: Needs work » Needs review
FileSize
8.89 KB

I 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.

BBC’s picture

Thanks 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.

akoepke’s picture

I 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.

akoepke’s picture

Status: Needs review » Fixed

This 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.

akoepke’s picture

I have just added the same functionality to the Drupal 9 version, 2.0.0-rc1 is now available.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.