1

I have a View listing out members of staff. Each staff member belongs to a department, or sub-department. I want to list out all staff members but group them under their (sub)-department in a nested manner. For example:

# School Board
John Doe

# Teaching Staff
Jane Doe

    ## Chemistry
    Eric Betzig

    ## Physics
    Shuji Nakamura
    Isamu Akasaki

I know you can use the Group by Fields option, as described in this answer, but it doesn't allow for nesting:

# School Board
John Doe

# Teaching Staff
Jane Doe

# Chemistry // Not nested
Eric Betzig

# Physics // Not nested
Shuji Nakamura
Isamu Akasaki
0

I think this is more a question of styling than views itself. You could assign a class to the row output (e.g. with a replacement pattern token or something) and then style the css to show the output "nested".

0

I ended up using the Views Field View module.

The logic is as follows:

  1. Create a View listing out the terms (I call it the 'Tree View')

    # School Board
    # Teaching Staff
    # Chemistry
    # Physics
    
  2. Create a View which takes a Contextual Filter of Content: Has taxonomy term ID and display all content with this term ID. (I call this the 'Content View')

    ## Physics
        Shuji Nakamura
        Isamu Akasaki
    
  3. We have the building blocks, now let's combine the two Views together. In the 'Tree View', add a relationship with the Parent term (Taxonomy term: Parent term) and add (Parent) Taxonomy term: Term Name to the fields. Now go to Format > Settings and Group the result by (Parent) Taxonomy term: Term Name and check 'Use rendered output to group rows'

    # School Board
    # Teaching Staff
        ## Chemistry
        ## Physics
    
  4. Still in the 'Tree View', add the (Parent) Taxonomy term: Term ID and Global: View fields. In the settings, under View, select your 'Content View', and under Contextual filters, put [!tid] in order to pass the term ID to the 'Content View'. And we are good to go!

    # School Board
    John Doe
    
    # Teaching Staff
    Jane Doe
    
        ## Chemistry
        Eric Betzig
    
        ## Physics
        Shuji Nakamura
        Isamu Akasaki
    

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.