Hi there,
Thanks for the useful module.
I've added a patch to save the taxonomy term lineage (a much requested feature).
This is useful for example when the content needs to store all the data points, to serve the data via API.
The current approach does as follows:
- Adds a checkbox to the form display widget settings to "Save lineage"
- If "Save lineage" is checked, the widget function
massageFormValues will transform the data to the lineage set on save
- If "Save lineage" is checked, the patch will alter the default settings on display to just set the taxonomy term "leaves" for the SHS widget render
It adds and uses a new class in Drupal\shs\Utility\TermLineage; based on the key code from the hierarchical select module.
Will attach the patch shortly.
Comments
Comment #2
davidwhthomas commentedComment #3
davidwhthomas commentedComment #4
davidwhthomas commentedComment #5
stborchertSorry to say, but closed as per #1893188-10: Save lineage.
SHS will never save the lineage as its not designed to do so (and never was), there is simply no use case having the complete lineage stored and you'll open up the box of Pandora by doing so.
Comment #6
davidwhthomas commentedSorry to hear that.
As the patch is working for our needs, we will use a local fork of the SHS module.
The patch can remain here for others wanting the save lineage functionality for Drupal 8.
Comment #7
diogo_plta commented"SHS will never save the lineage as its not designed to do"
I hadn´t imagined this module whitout this function. For me it is designed for this. Why save only the last item?
Can you explain? I think that a lot of people want this function.
Comment #8
proweb.ua commentedThanks @davidwhthomas, the patch #2 works.
I used it as a replacement for 'Content: Has taxonomy term ID (with depth)' filter.
If you are using /taxonomy/term/% + search api, filter 'Content: Has taxonomy term ID (with depth)' is missing.
It may be better to design a patch in the form of a separate module. If they do not want to accept it.
Comment #9
skinOr you can use https://www.drupal.org/project/term_reference_tree
Comment #10
mtoscano commentedThe ideal solution will be to update https://www.drupal.org/project/taxonomy_set_lineage to Drupal 8
Comment #11
bakinbox commentedHi, i´m trying to apply the path #2 but seems is ok, but can´t fine some files. I can see in the form "Save lineage", but the contents get a white death screen.
EDIT, i could apply the patch (git apply -v shs-save-term-lineage-2943357-2_2.patch) but now i it has other problems.
The field need to have no limits no 1.
And in the field only gets the first (the parent or root term, not the others)
Thanks.
Comment #12
bakinbox commentedAnybody knows how to solve it? thanks
Comment #13
rhristov commentedI have created a new patch based on the one from comment #2 and I have fixed the following issue: When editing already created content and saving it without any new modifications an error appears: "You need to select a term from the deepest level in the field FIELD_NAME".
Comment #14
rhristov commentedApplying a new patch that is exposing an option to hide the Add another button link.
Comment #15
rhristov commentedCreated a new patch from #14 that is fixing the notices.
Comment #16
jbfelix commentedwhen do you plan to commit this patch ?
Thanks
Comment #17
alaa abbad commentedComment #18
ooz47 commentedPatch from comment #15 applies cleanly!
Thank you!
Comment #19
summit commentedHi, t would be great if this could be ported to D7! Greetings, Martijn
Comment #20
summit commentedNow experimenting on D8. Why wouldn't this patch not be committed. It is a big missing feature in D8, save term lineage?
Thanks for considering this, greetings, Martijn
Comment #21
summit commentedHi, Yes this term lineage works great. A very good add-on to this module.
Please, please, module-maintainer...this is the only HS module on which with patches:
1- We can add new terms to lineages: https://www.drupal.org/project/shs/issues/2712115
2- With this patch, also save the term lineage.
With this finally the Hierarchical Select module, which stopped in D7, has a replacement in D8.
Please do not stop this great functionality, and please bring it within this great SHS module, because there is a need for this.
And shouldn't modules supposed to exactly do that? Fill a need?
Thanks for considering, and therefore I set this patch to Reviewed & Tested ok?
Greetings,
Comment #22
summit commentedDouble input, sorry.
Comment #23
vm commented@Summit - The project page indicates that the maintainers are no longer developing this module. Someone will need to take apply to take it over for patches to be committed and new releases to be provided.
Comment #24
summit commentedHi VM, Thanks for bringing this to my attention. I am not enough programmer for this. Hopefully someone will fill the gab!
greetings, Martijn
Comment #25
mstiI am marking this as fixed. The patch has been added to the module.
Comment #27
summit commentedThanks Mike Stivaktakis. Great addon!
Comment #28
seutje commentedIt doesn't appear this patch was actually added.
Also, it produces an issue when using terms with multiple parents.
Situation as follows:
child 1 has both term 1 and term 2 as parent.
- term 1
-- child 1
- term 2
-- child 1
When I select term 2 and child 1 and save the node, the field contains the values for term 1, term 2 and child 1.
Comment #29
summit commentedHi, You should change the Status from Closed/Fixed to what you need to get attention again for this issue I think.
greetings,
Comment #30
jmaties commentedCompatibility with drupal 9
Comment #31
summit commentedHi Javier,
Will your Version 2.0.x-dev also work with Drupal 8 and is issue #28 (https://www.drupal.org/project/shs/issues/2943357#comment-13971871) solved with it ? Or is it easy to make it compatible with drupal 8?
Thanks for your reply in advance, and sorry if this is a stupid question. I am not working with Drupal 9 yet.
greetings, Martijn
Comment #32
summit commentedHi,
I am testing Drupal 9.2.8 now, and got this with latest SHS 2.x.dev.
Could you please alter the patch as such it is working with latest 2.dev.
I do not know how to see where in the patch it goes wrong, sorry.
Made a new issue to move forward on Drupal 9, see https://www.drupal.org/project/shs/issues/3248983
Thanks a lot in advance for your reply.
Greetings, Martijn
Comment #33
volegerRerolled #30
Indeed this is a missing feature in the 2.0.x branch. The issue needs to be reopened or moved to follow-up issue.
Comment #34
volegerFixed typo
public function getParents(int $tid): number=>public function getParents(int $tid): arrayComment #35
volegerSmall fix on the default value
Comment #36
summit commentedHi,
Is this patch still needed?
When I combine SHS with https://www.drupal.org/project/taxonomy_set_lineage it will save the lineage.
See also this post: https://www.drupal.org/project/taxonomy_set_lineage/issues/2872601#comme...
But the disadvantage is that I have to alter every node now to have the lineage set. May be there is a bulk solution for this?
greetings, Martijn
Comment #37
summit commentedHi, I let made a Drupal 10 Save term lineage patch, see https://www.drupal.org/project/shs/issues/3409930
greetings,
Comment #38
maria.valcheva commentedPatch altered to work with the latest release (2.0.0-rc12).
Comment #39
nnevillPatch from #38 works well with 2.0.0-rc12
Comment #40
nnevillAfter more testing found that patch from #38 throws errors in case of multiple SHS fields and in case field is empty so here is updated patch with interdiff.