Hi,

I would need the save lineage option for the project I am on. Is there a plan for adding it ?
I saw the multiple selection has been enabled so it should not be too long.

I will try but regards to my experience with drupal dev, i can take a while...

Comments

wim leers’s picture

Title: Save linegae option » "Save lineage" support — sponsorship needed
Component: Code - Content Taxonomy » Code - Taxonomy
Status: Active » Postponed (maintainer needs more info)

If you don't have a lot of experience with Drupal development, then I don't recommend diving in yourself. HS is a highly complex module.

"Save lineage" support will only be added to HS3 if it gets sponsored (or contributed, of course). It will definitely be included in the rewrite of HS, HS 4.

supportPIC’s picture

ok, since I have lot of stuff to do I won't try it for the moment. If I manage to do it sometime I will post a patch...

dgastudio’s picture

Wim, how much will cost:

1.views integration.
2. save lineage feature.

??

wim leers’s picture

kervi, I can't work on this until July probably. I think that won't be fast enough?

bancarddata’s picture

I am willing to put up half of the cost for implementing multi-parent/save lineage support in HS3 if anyone wishes to co-sponsor. We are slated to have this project started on the week of July 10.

dgastudio’s picture

first, i would like to know the final cost of the development and if Wim is available to do it.

bancarddata’s picture

Wim said he was available to do it next week and has quoted me 8 hours development time.

bancarddata’s picture

OK, I am now willing to put up the entire cost to just get the save lineage/multi-parent functionality working in D7. Any takers? I believe Wim is extremely busy again. I can relate or I would try to take this on myself.

hozt’s picture

I also need this same functionality for a project and have come up with a workaround that will work for my use case until the module is fully ported. I just have two levels in my hierarchy so this may not work for you if you have more.

I created another standard list type term reference field for my entity and set the tree depth to 1. This will hold the parent value of my hierarchy. Then I wrote a custom module that uses hook_entity_presave() to get the parent value from the hierarchy and store it to this new parent term. This example is for entity, but you could use the hook_node_presave() if this is a node.

function YourCustomModule_entity_presave($entity, $type) {
	if ($type == "commerce_product") {
		// Get the parent term_id of the child.
		$taxonomy_parent_id = array_keys(taxonomy_get_parents($entity->field_term_department[LANGUAGE_NONE][0]['tid']));
		if ($taxonomy_parent_id) {
			// Save the parent
			$entity->field_term_department_parent[LANGUAGE_NONE][0]['tid'] = $taxonomy_parent_id;
		}
		return $entity;
	}
}

Then I hid this term from the edit form. Having this extra parent term now allows me to use views and get all the parent entities (commerce products in my case) which is not yet supported in this module.

yareckon’s picture

StatusFileSize
new1.75 KB

Here is a little module that is a bit more general than the last above solution.
You can simply set a vocabulary to make sure that all parent terms are selected every time an entity is saved.
The lineage feature in Heirarchical select should still be implemented, as it is per field rather than per taxonomy.

zeezhao’s picture

subscribing. thanks

dgastudio’s picture

it doesn' work for me

after create 3 levels vocabulary, add a term field with HS widget, enable your module, set the correct vocabulary to "Taxonomies with Lineage" create any new node, set three levels of term field and save, only the last term is saved.

yareckon’s picture

kervi, is there internationalization involved here? I've realized that my module doesn't really account for that.

yareckon’s picture

kervi, your taxonomy also has to be set to allow more than one value.. If your taxonomy only allows a single value in the field settings, my module can't do anything :)

dgastudio’s picture

13.. yep.. internationalization is activated...
14.. it's set.

justmagicmaria’s picture

@yareckon, thank you! Your little module was exactly what I needed. I don't know why that feature is not in core. It seems to me the most common case for a hierarchical vocabulary is to want to save the lineage.

Editing to add that it worked fine for me once I set the vocabs through the config form (before that it was complaining about an invalid foreach argument on line 62 of taxonomy_set_lineage.module).

wim leers’s picture

wim leers’s picture

Comments #9—#16, hah, strange to see an entirely new module being born in a single issue of another module's issue queue! Maybe you should submit this as a new module on Drupal.org? After all, your module is *much* simpler and covers a similar, yet different use case than HS Taxonomy with its "save lineage" functionality.

I've started the implementation of "save lineage" support for D7. bancarddata is sponsoring it.

wim leers’s picture

Title: "Save lineage" support — sponsorship needed » Port "save lineage" functionality to D7
Assigned: Unassigned » wim leers
Status: Postponed (maintainer needs more info) » Fixed

Committed: http://drupalcode.org/project/hierarchical_select.git/commit/acac369. Thanks again to Bancard Data Service for sponsoring this!

Please report if everything is working correctly. If it is, I will do a third alpha release.

dgastudio’s picture

Wim

trying to edit field gadget options.
Fatal error: Call to undefined function tt() in /home/*****/sites/all/modules/hierarchical_select/modules/hs_taxonomy.module on line 939

dgastudio’s picture

StatusFileSize
new56.61 KB

upd. i have i18n enabled with taxonomy. See attached screenshot.

wim leers’s picture

That's unrelated to this issue. Line 939 (which is part of _hs_taxonomy_hierarchical_select_terms_to_options()) was not changed as part of the above commit. Could you please give it a try without i18n?

(P.S.: see #1216214: D7 i18n Taxonomy compatibility for HS Taxonomy + i18n in D7, I actually made a commit for this just a few days ago, and fietserwin, the guy who posted the patch, is actually using i18n. So this is quite strange for me. Maybe there are different versions of i18n? But please, let's continue in that issue.)

wim leers’s picture

Title: Port "save lineage" functionality to D7 » Port "save lineage" functionality to D7 + support for multiple parent taxonomies

bancarddata reported that he was still seeing a "This is a vocabulary with multiple parents. The Drupal 7 port of Hierarchical Select does not yet support this." message. I then realized that I had actually forgotten to enable/test multiple parents functionality: I had only worked on the "save lineage" functionality. I had simply forgotten about that.
While fixing that, I also found http://drupal.org/node/1068070#comment-4840346 (solving #1068070: When multiple HS widgets exist on the same page, and #process order != displayed order: Drupal's JS setting handling breaks HS!) and noticed that it may be impossible to create multiple parent hierarchies (if you upgraded from a D6 site with HS) because taxonomy_override_selector apparently still exists for the Taxonomy term create/edit form. Hence, I also implemented the ability to use HS to select parent terms.

All of the above has been committed: http://drupalcode.org/project/hierarchical_select.git/commit/e2b1c3c.

davidwhthomas’s picture

Great to see the "Save term lineage" functionality being worked on.

Unfortunately, updating to -dev to add this feature caused my field_section term reference field to lose all existing data on node save.

The data still appears to be in the database, but when editing a node, the hierarchical select widget shows as default/empty with no terms selected..

UPDATE: Just an update to this, I suspect this is because existing tagged nodes don't have the parent term saved as well, only the child term, so it shows up as empty in the drop box, with nothing selected..

davidwhthomas’s picture

OK, I fixed the above issue using yareckon's useful module from #10

1. Install and configure taxonomy_set_lineage for required vocabularies
2. Created a views_bulk_operations view with a 'save content' action
3. Batch re-saved all relevant nodes, this set the term lineage as per taxonomy_set_lineage module
4. Configured hierarchical_select to 'save term lineage'

Done.

Editing an existing node now correctly shows the term lineage.

Thanks again for the excellent module.

DT

wim leers’s picture

@davidwhthomas: Yes, that would cause problems. Glad you sorted it out! :)

zeezhao’s picture

Wim - when migrating from D6 to D7, please can you confirm what to do to ensure all previous lineages are retained? Or do we also have to follow #25? Thanks.

wim leers’s picture

@zeezhao: storing lineages does not involve anything special: simply all terms are stored by Taxonomy. You don't have to do anything special: Drupal core's upgrade path also automatically migrates all Taxonomy terms, so there's absolutely nothing you have to do or worry about! :)

zeezhao’s picture

Thanks for reply. The reason I ask is in a D6 to D7 conversion test I did, all the lineages for existing nodes in D7 do not show up when editing the nodes i.e. HS selection is none even though old data indicates otherwise. Whereas they were fine in D6 database.

wim leers’s picture

Is this using content_taxonomy, maybe?

Also, did you reconfigure your HS widgets? Not all settings are migrated.

zeezhao’s picture

Yes, the HS widgets were reconfigured. Yes, it is also using content_taxonomy. Thanks

[edit]
To add - the weird thing is when I did a conversion a few weeks ago with an older version of HS 7.x, CT, etc., it appeared to work then....

wim leers’s picture

There have been no changes to HS or HS Taxonomy that could have broken this. It must be the upgrade path of CCK -> Field API or Content Taxonomy.

Also: I'm not going to help with debugging Content Taxonomy upgrade path misery. That module has cost me enough days of misery already. I hope you understand :)

zeezhao’s picture

I reran upgrade using a version of cck I used in past from March 2011, and it now works well. So issue appears to be content_migrate related...

wim leers’s picture

Yes, that's what I was afraid of… Hopefully this is your final part of the upgrade, so you can do the final migration and be done with it? :)

zeezhao’s picture

Thanks. Well... upgrade is quite complicated, so still have to wait/do loads of other module stuff e.g. cck & multigroups, some aspects of notifications, quiz, HS and limit depth..., and more...

Just trying to ensure that critical issues are solved first. In reality, there is no visible benefit to the upgrade, other than keeping up-to-date... Thanks, anyway.

Status: Fixed » Closed (fixed)

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

dxhuong’s picture

Amazing module.
Thanks !

mikeguzman’s picture

Version: 7.x-3.x-dev » 7.x-3.0-alpha5
StatusFileSize
new2.11 KB

Hi I updated the yareckon's module from #10 because with the latest version of Drupal 7 I had issues. I want to share this improvement because this module helped me a lot.

Same steps:

1. Install and configure taxonomy_set_lineage for required vocabularies
2. Set the term lineage as per taxonomy_set_lineage module
4. Configured hierarchical_select to 'save term lineage' with multiple parent taxonomies
5. Voila!!! you have now the full term lineage with all the related parents.

jramby’s picture

Status: Closed (fixed) » Active

Hi, just a question, is it available on which version?

thanks!

jramby’s picture

Status: Active » Closed (fixed)

Sorry, I missed something... I just saw it in the time.

Again thank you... it's a great module!!

jonofthedead’s picture

Issue summary: View changes
StatusFileSize
new2.25 KB

Hello,

Recently I ran into this issue but at the end of the day decided not to use Hierarchical Select due to a bug in the create new functionality. So I adjusted the Module in #38 (which was adjusted from #10) to work with the standard "autocomplete term widget (tagging)" widget.

Issues I found in #38 when using with the standard widget -
1) when tagging multiple values if two terms have the same parent, the parent term was displayed twice.
2) when adding new terms, the new term would be added twice

I resolved both by first creating an array of all of the TID's for all the terms stored in the entity->{$tag_field_name}. Then the second time through the terms list I then grab all the parents for each term then check each parent if the TID is in my "already defined" array. if not I insert it into the entity and my array.

I realize going through twice can be a huge timesink if you have a large number of terms, but it worked for me since this is done on a save and will not affect my viewers, only contribs (which is me and 1 other person at the moment).

If you are reading this and revisit to find a better way please let me know!

Hope this helps others!

Setup:
1) Install taxonomy_set_lineage
2) go to admin/config/content/taxonomy_set_lineage to configure required vocabs
3) make sure you are using the standard "autocomplete term widget (tagging)" widget for your taxonomy field (other widgets might work but haven't tested!)
4) you are good to go!

Jonathan.