Views Field View
Allows embedding a View as a field within another View, enabling hierarchical view relationships with token-based argument passing.
views_field_view
Overview
Views Field View is a powerful Views extension module that enables you to embed one View as a field inside another View. This creates a parent-child relationship between views, where the child view can receive contextual arguments from fields or arguments in the parent view.
The module adds a new field type called 'Global: View' to the Views field handlers. When you add this field to a view (the "parent" view), you can select any other view (the "child" view) to be displayed for each row in the parent view. The child view can accept argument values from the parent view using a comprehensive token system.
This is particularly useful for creating complex data relationships, such as showing related content for each item in a list, displaying nested hierarchies, or creating dashboard-style views where each row contains summarized data from another view.
Features
- Embed any View as a field within another View, creating parent-child view relationships
- Token-based argument passing system supporting both raw and rendered field values
- Support for contextual filter tokens ({{ raw_arguments.X }} and {{ arguments.X }}) to pass parent view arguments to child views
- Support for field tokens ({{ raw_fields.X }} and {{ fields.X }}) to pass parent view field values as child view arguments
- Multiple token delimiters supported: comma (,) or forward slash (/) for separating multiple arguments
- Static value support - pass fixed IDs or taxonomy terms directly to child views
- Built-in recursion protection to prevent infinite loops when views reference each other
- Automatic pager ID rewriting to ensure child view pagers work correctly within parent views
- Direct link to edit the child view configuration from the parent view field settings
- Access control - child views only render if the current user has access to the selected display
- Hide empty option integration - suppress output when child view returns no results
Use Cases
Display related content for each item
Create a parent view listing articles, and embed a child view showing related content for each article. Pass the article's node ID ({{ raw_fields.nid }}) to the child view's contextual filter to display related items based on taxonomy terms or other relationships.
User dashboard with activity summary
Build a view of users with an embedded child view showing each user's recent activity (comments, content authored, etc.). Pass {{ raw_fields.uid }} to filter the child view to show only that user's activity.
Category listing with item counts or previews
Create a taxonomy term listing view with an embedded child view showing the latest 3 nodes in each category. Pass the term ID ({{ raw_fields.tid }}) to the child view to filter content by category.
E-commerce product variants
Display products with embedded views showing available variants, pricing tiers, or stock information. Pass the product ID to child views that display variant-specific data.
Hierarchical content navigation
Build nested navigation structures where a parent view shows top-level items and embedded child views show sub-items. Use the parent item's ID or path as an argument to filter children.
Multi-level aggregation reports
Create summary reports where the parent view shows groupings (by date, category, user) and child views provide detailed breakdowns or statistics for each group.
Tips
- Position fields used as argument tokens ABOVE the Global: View field in the field list, as Views processes fields in order
- Use 'Exclude from display' on fields that are only needed for passing as tokens to avoid cluttering the output
- Use {{ raw_fields.X }} tokens for cleaner data (no HTML formatting) when passing IDs or values as arguments
- Use {{ fields.X }} tokens when you need the rendered/formatted output, but be aware this includes any rewriting applied to the field
- Enable caching on child views to improve performance, especially when the same child view is embedded multiple times
- For complex argument logic, consider using Views PHP or custom code to prepare argument values
- Test child views independently with manual arguments before embedding to ensure contextual filters work correctly
- Use the 'Edit view' link in the field configuration to quickly access and modify the child view settings
- When using multiple arguments, ensure they are separated by commas or forward slashes and in the correct order matching the child view's contextual filters
Technical Details
Hooks 1
hook_views_data_alter
Adds the 'view' field handler to the global Views data, making the 'Global: View' field available in all views.
Troubleshooting 6
This occurs when a view attempts to embed itself, creating an infinite loop. Ensure your parent and child views are different, or that the display being embedded is not the same as the current display. The recursion protection is working as intended.
Ensure the fields you're using as token sources are positioned ABOVE the Global: View field in the field list. Views processes fields in order, so tokens from fields below are not available. Also verify the token format matches exactly: {{ raw_fields.field_name }} or {{ fields.field_name }}.
Save the field configuration first after selecting the view. The display options require a valid view to be selected and saved before they appear due to the two-step AJAX loading process.
The module automatically assigns unique pager IDs to child views based on row index. If multiple child views per row need pagers, you may encounter conflicts. Consider using 'mini' pagers or disabling pagers on child views in favor of 'more' links.
Each row in the parent view executes the child view query separately. Enable caching on the child view (Views cache settings), reduce the number of parent rows with pagers, or consider using Views aggregation instead for simple counts.
Check that the current user has access to the child view's display. The module respects view access permissions and will not render views the user cannot access.
Security Notes 4
- The module respects Views access permissions - child views only render if the current user has access to the selected display
- Static string arguments are HTML-escaped before being passed to prevent XSS vulnerabilities
- Recursion protection is enabled by default to prevent denial-of-service through infinite loops
- The 'evil' configuration setting should only be enabled by developers who understand the security implications of allowing recursive view embedding