views_field_view
The Views Field View module is a powerful tool for site builders who need to create nested data structures. It allows you to embed one view as a field within another, creating a "view-within-a-view" architecture that handles complex relationships with ease.
How It Works
The module provides a specialized field handler for Drupal Views. When you add this field to your "Parent" view, you can select a "Child" view to display inside it. Most importantly, it allows you to pass contextual filters (arguments) from the parent row - such as a Node ID or User ID - directly into the child view to ensure the embedded data is relevant to that specific row.
A Common Use Case: Nested Memberships
Example: building a directory of Groups. In main list, you want to show the group's name and description, but you also want to display a sub-list of the first and last names of all members belonging to that specific group.
- The Parent View: Lists the Groups.
- The Child View: Lists User names, filtered by a Group ID.
- The Connection: Views Field View passes the Group ID from the parent row into the child view’s contextual filter.
Performance & Caching
Because nesting views can be resource-intensive (as it triggers additional database queries for every row in your list), caching is highly recommended. To keep your site fast and responsive, consider using advanced caching strategies:
- Views Content Cache: Automatically clears the view cache when specific content types are updated.
- Cache Actions: Provides Rules integration to trigger cache clearing based on specific site events.