7

I have a taxonomy with a three-level hierarchy, and would like to display the three levels in a views table, but separately. I'd also like to have an exposed filter using that taxonomy and let my users pick the term.

Here's what I've done:

  1. Added the contextual filter Has taxonomy term id depth modifier
  2. Added the relationship Content: Taxonomy terms on node with an identifier "term"
  3. Added the relationship Taxonomy term: Parent term with an identifier "Parent" and set its relationship as "term"
  4. Added the contextual filter Taxonomy term: Parent term and selected the "Parent" relationship
  5. Added the taxonomy term field

At this point I can display the hierarchy in a single column and can choose between the lowest level child or all three (e.g. Grandparent > Parent > Child). However, I want to be able to display the grandparent, parent and child in separate columns.

Is this possible? I was hoping to maybe add the field three times and pick the hierarchy level, but I don't see how to do that.

3 Answers 3

3
+50

If you've only 3 level of hierarchy then you can create a view as below:

enter image description here

Above view should give the output as below: enter image description here

Hope this helps.

0

First you need to generate the desired 3 column table without Views. Then you can use Views's to load the desired nodes with contextual filters. Possible to do following the stes below, but there is many different ways to do.

  1. Create a module with the mymodule_taxonomy_get_tree_nested() function
  2. call it from the template.php
  3. figure out what and how do you want to display
  4. you can render Arrays with Drupal after some "makeup"
  5. load the desired content with View, using the Content: Has taxonomy term ID contextual filter
0

Also. I believe, you can use ready-done module for it https://www.drupal.org/project/views_tree.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.