This feature is to automatically tag parent term when child term is selected. Patch is attached.

Comments

hypertext200’s picture

Status: Active » Needs review
StatusFileSize
new3.31 KB
arpieb’s picture

Thanks for the suggestion and patch! I'll check it out and if all's well commit it to the dev branch.

Looks like this addresses one of the feature requests in #1728132: Add field instance settings "leaves only" and "select parents automatically".

charlie charles’s picture

@#1 Thanks for the patch.
I've tested it

I get the parent term showing up twice
using any hierarchical display setting i.e

hierarchical_term_formatter or hierarchical_select

for example

  • London
  • London > North London
interdruper’s picture

New patch is attached, based on #1987168-1: Auto tag parent term when child term is selected).

Changes from #1987168-1: Auto tag parent term when child term is selected:

  1. the option includes now all the ancestors, not only the direct parents. Basically it is achieved using the function taxonomy_get_parents_all() instead of taxonomy_get_parents(). I think that including all the ancestors has a wider scope, more useful.
  2. the ancestors are inserted preserving their hierarchical order. A small processing has been required here.

A sample use case:
Including all the ancestor terms may be very useful for making easier some searches, using filters and/or facets.
e.g:
in a hierarchical vocabulary like:

Europe
        |
        ----- Spain
                      |
                       ------ Madrid

selecting 'Madrid' will include all the 3 terms in the field, preserving the hierarchical order.

Rustan’s picture

Status: Needs review » Reviewed & tested by the community

#4 works well for me.

  • arpieb committed d6dcefd on 7.x-1.x authored by interdruper
    Issue #1987168 by heshan.lk, interdruper: Auto tag parent term when...
arpieb’s picture

Status: Reviewed & tested by the community » Fixed

Merged to 7.x-1.x, deployed on release 1.0-alpha3. Thanks for the contributions!

arpieb’s picture

Status: Fixed » Closed (fixed)