Hi all,

Views has only parent selection Relationship. Why not having child Relationship?
Providing simple patch for that.

Use case

Products catalog of fixed-level depth, where products are tagged with lowest level terms (leafs). And now need to output the products, divided into categories, say - price-list.

1) Create a taxonomy View
2) Add Contextual filter for Parent Term, and set Fixed value = 0 (to select only root of the tree)
3) Add this new Relationship - Child terms.
4) Repeat (3) until low-level reached
5) Add Taxonomy content Relationship to select products.

Members fund testing for the Drupal project. Drupal Association Learn more


liquidcms’s picture

Status: Active » Reviewed & tested by the community

thanks for this; seems to be just what was needed. odd this wasn't there already.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, adding_child_terms_relationship.patch, failed testing.

fehin’s picture

This sounds like a great idea.

erikwebb’s picture

Version: 7.x-3.1 » 7.x-3.x-dev
Status: Needs work » Needs review
1.14 KB
PASSED: [[SimpleTest]]: [MySQL] 1,658 pass(es). View
philipz’s picture

Wow after such long time and just when I thought about it here it is :) Thanks! It works for me fine.

Now if only I could select this relationship in representative node relationship this would be awesome. I'll open a new issue for that and link to patch #4.
My mistake - relationship order matters :)

TimelessDomain’s picture

Status: Needs review » Reviewed & tested by the community
Summit’s picture

Issue summary: View changes


Could like this also child terms for node-views be build?

Greetings, Martijn

colan’s picture

We've recently switched our testing from the old qa.drupal.org to DrupalCI. Because of a bug in the new system, #2623840: Views (D7) patches not being tested, older patches must be re-uploaded. On re-uploading the patch, please set the status to "Needs Review" so that the test bot will add it to its queue.

If all tests pass, change the Status back to "Reviewed & tested by the community". We'll most likely commit the patch immediately without having to go through another round of peer review.

We apologize for the trouble, and appreciate your patience.

OnkelTem’s picture

Status: Reviewed & tested by the community » Needs review
770 bytes
OnkelTem’s picture

@colan what is it waiting for? (no testing)

colan’s picture

Tests don't run until the branch passes on its own. We just got it to pass again now so it looks like all of the tests are automatically re-queueing. There will be a large number of them now so please be patient.

Status: Needs review » Needs work

The last submitted patch, 9: features-drupal_static_reset-2.patch, failed testing.

OnkelTem’s picture

Status: Needs work » Needs review
1.14 KB

Oh, crap, I've uploaded the wrong patch :)
Uploading again, the #4th by erikwebb

ibis’s picture

Works very well to select only parent terms what have content even only on children term! And the grouped by count-distinct on the related node-ids gives count of all content from childrens. Thanks!

demonde’s picture

Works very well. When will it be contributed to dev?

darrenwh’s picture

Status: Needs review » Needs work
  1. +++ b/modules/taxonomy.views.inc
    @@ -370,6 +370,31 @@ function taxonomy_views_data() {
    +  // ----------------------------------------------------------------------

    I don't think this comment is in line with DCS? perhaps omit -----?

  2. +++ b/modules/taxonomy.views.inc
    @@ -370,6 +370,31 @@ function taxonomy_views_data() {
    +  // term_hierarchy table (reversed)

    Should capitalise first letter and add a period (.) at end.

frob’s picture

Status: Needs work » Needs review
1.04 KB

Rerolled patch to better conform to Drupal Coding standards for documentation.

Status: Needs review » Needs work

The last submitted patch, 17: views-term_child_relationship-1437494-17.patch, failed testing.