0

I am using Views Field View module. I need to filter the child view using the parent field. Can anyone experienced in it please share.

3

You will have to send a contextual filter from your parent view and catch it in your embedded view. There are plenty of tutorials on contextual filters, but this one should get you started: http://www.metaltoad.com/blog/using-drupal-contextual-filters-views

UPDATE you can set a contextual filter from your parentview by editing the embedded view in 'fields' and define it in the view-settings drop-down.

3

As I had a lot of trouble setting context filters properly for Views Field View, and couldn't find any documentation on the subject or proper answers, I'll provide more detailed walk-through here:

I want to have a list generated like this from different content types:

  • First group of things
  • Some data about that group

    • name of first thing from that group
    • name of second thing from that group
  • Second group of things

  • Some data about that second group

    • name of first thing from the second group
    • name of second thing from the second group

  1. I've created parent view "my_group_of_things" showing fields from content type "my_group"
  2. I've created child view "list of things" showing fields from content type "thing"
  3. The content type "thing" has a field ("field_my_group") of type node reference that references to selected "my_group" and has a label "Content: MyGroup"
  4. In parent view ("my_group_of_things") I add field Content: Nid
  5. In the same parent view I add field Content: View and set it to "list of things"
  6. While setting the Content: View field I enter [!nid] in the CONTEXTUAL FILTER text box
  7. Don't forget to apply the Content: View and save the View
  8. In child view ("list of things"), in ADVANCED tab, I add a CONTEXTUAL FILTER
  9. While setting this contextual filter I choose Content: MyGroup (field_my_group)
  10. In the same contextual filter I set WHEN THE FILTER VALUE IS NOT AVAILABLE to "Hide view"
  11. Apply and save. It should work now.

Very simple, but without documentation and arrogant answers like "yeah, i got it now", or "just set up contextual filter" it took me a whole day to figure out.

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.