Problem/Motivation

When a taxonomy reference field allows to select terms from more than one vocabulary, they are all merged into the same tree which can be really confusing.

Proposed resolution

Allow site builders to define how to handle multiple vocabularies:

  • By merging terms in the same tree (current behavior and default one to preserve BC)
  • By having all terms in the same tree but under a different root per vocabulary
  • By having one different tree per vocabulary

Remaining tasks

Create a patch
Review
Commit
Enjoy :)

User interface changes

The widget has a different behavior given its settings.
A new field is exposed on the widget configuration form.

API changes

None.

Data model changes

A new setting appears on the widget.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DuaelFr created an issue. See original summary.

DuaelFr’s picture

Title: Dael with multiple vocabularies » Deal with multiple vocabularies
Issue summary: View changes
Status: Active » Needs review
FileSize
11.09 KB

I did a bunch of tests on my own but I'll definitely need more eyes on this one.

FYI, it's applying properly with #2837672-22: Allow to configure widget settings via composer.

DuaelFr’s picture

FileSize
5.87 KB
8.43 KB
9.54 KB

Here are some screenshots!

Default behavior / "Merged" mode

"Tree root" mode

"Cloned" mode

texas-bronius’s picture

@DuaelFr Your work is not falling on a deaf crowd! :D I confirm this works as described and in conjunction with #2837672-22: Allow to configure widget settings.

However, is this same issue the right place to also bring up Tree widget display config representing several Vocabularies?

Right now what I see looks something like:

Field Label

  • term1
  • term2
  • term3
  • term4
  • term5
  • term6

But what I am looking for is the option to see something like:

Field Label

  • Vocab1
    • term1
    • term2
    • term3
  • Vocab2
    • term4
    • term5
    • term6

I won't set out in this direction if it exists and I just don't see it or if it's buried in the issue queue somewhere else that I'm not seeing it. In either case, I believe it should be an option rather than a forced output. Unless it somehow automatically corresponds to the Form Config.. that might be intuitive and interesting..

nessthehero’s picture

The patch in #2 works for me as well! However, it can't be applied automatically anymore, due to some minor code changes since it was created. I had to apply it manually.

This is a substantial improvement to taxonomy overall in Drupal, in my opinion. Currently I build content types that need multiple vocabularies with a reference field for each vocabulary, and with this change I would only need one field per content type, with the freedom to add or remove taxonomies easily in the future without code adjustments to any preprocessing. A client could conceivably create new Vocabularies in the future when needs arise and add them to existing taxonomy fields without ANY developer support!

I would love if this was rolled into this module officially. This is a gem of a change.

DuaelFr’s picture

I've tried to reroll this on the latest dev.
I have no project to try it on right now so be careful :)

mjmorley’s picture

I've updated the patch from #6 and it is now compatible with Drupal ^9.3.
This is a great addition to the module.
Thankfully not much code change was needed. The patch applied cleanly for me using composer, and from my testing seems to work well.

Info about the patch:
Built and tested with

  • drupal/core 9.3.16
  • drupal/term_reference_tree 1.1.0
  • php 7.4

Sadly the only automatic tests I see are for the 7.x-dev branch, so I won't run any on this patch.

tgauges’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Component: Code » User interface
Assigned: Unassigned » tgauges
Status: Needs review » Active

tgauges’s picture

Assigned: tgauges » Unassigned
Status: Active » Needs review

I applied this issue's patch to version 2.0.x of the project. Only one location needed a small adjustment.