Insert View

An input filter that allows embedding Views into text content using a simple tag syntax.

insert_view
10,206 sites
37
drupal.org

Install

Drupal 11, 10, 9, 8 v3.0.0
composer require 'drupal/insert_view:^3.0'

Overview

Insert View provides a powerful text filter that enables content editors to embed Drupal Views directly within text content using a simple, intuitive tag syntax. This allows dynamic, database-driven content to be placed anywhere within nodes, blocks, or any text field that uses a text format with this filter enabled.

The tag syntax follows the pattern [view:name=display=args=limit:number], where you can specify the view name, display ID, arguments, and optionally limit the number of results. The filter supports dynamic argument replacement from the current URL, making it possible to create context-aware embedded views.

When processing content, the filter uses Drupal's placeholder system for lazy rendering, which helps with performance optimization. It also respects view access permissions, ensuring users only see views they have permission to access.

Features

  • Embed any Views display into text content using simple bracket syntax [view:name=display=args]
  • Support for view arguments with multiple arguments separated by slashes
  • Dynamic URL argument replacement using %0, %1, %2 placeholders that map to current URL path segments
  • Optional limit parameter to override the view's default items per page setting (limit:0 shows all results)
  • Automatic access control checking respects view display access permissions
  • Lazy rendering using Drupal's placeholder system for improved performance
  • Falls back to default display when no display ID is specified
  • Filter tips and help text displayed on content editing pages

Use Cases

Embed a Recent Content View in a Page

Add a list of recent blog posts within a static page's body content by using [view:blog_posts=block_1] to display the block_1 display of the blog_posts view.

Display Related Content Based on Current Node

Use URL argument replacement to show related content. For example, [view:related_content=default=%1] where %1 captures the node ID from the current URL path to filter related items.

Create a Dynamic Landing Page

Build rich landing pages by combining static content with multiple embedded views using tags like [view:featured_products], [view:testimonials=block], and [view:latest_news=default=5] to create a dynamic page layout.

Limit Results in Embedded Views

Override the view's default paging by using the limit parameter. For example, [view:team_members=default==limit:3] shows only 3 team members regardless of the view's configured items per page.

Pass Multiple Arguments to Contextual Filters

When a view has multiple contextual filters, pass arguments separated by slashes: [view:product_list=default=electronics/featured] passes 'electronics' as the first argument and 'featured' as the second.

Tips

  • Create a dedicated text format named 'Full HTML with Views' to separate content that embeds views from regular content, allowing better cache management
  • Always test embedded views with different user roles to ensure access permissions are correctly configured
  • Use the view preview screen to verify the correct display ID - hover over display tabs to see the ID in the URL
  • When using argument replacement, the %0 placeholder corresponds to the first segment after the domain in the URL path
  • Use limit:0 to display all results when you need to show everything regardless of pager settings
  • The default display is used automatically when you omit the display parameter: [view:my_view] is equivalent to [view:my_view=default]

Technical Details

Hooks 1
hook_help

Provides help text for the Insert View module on the help page

Troubleshooting 4
View is not rendering or shows blank output

Verify the view name and display ID are correct. Check that the current user has access to the view display. Ensure the view exists and is enabled.

Arguments are not being passed correctly

Make sure argument placeholders (%0, %1, etc.) match the URL structure. Remember that %0 corresponds to the first URL segment. Multiple arguments should be separated with forward slashes.

Page caching issues with embedded views

Insert View disables render caching for text formats that have it enabled. Consider creating a separate text format specifically for content that needs embedded views to minimize caching impact on other content.

Access denied even though view appears accessible

Check both the view's access settings AND the specific display's access settings. The filter checks access for the specified display, not just the default display.

Security Notes 4
  • Only grant this filter to trusted user roles as it allows embedding any view the user has access to
  • Ensure ALL view displays (including default) have proper access controls configured, as users with this filter can attempt to embed any display
  • The filter respects view access permissions but relies on proper view configuration - a misconfigured view with 'unrestricted' access could expose sensitive data
  • Consider the security implications of allowing dynamic argument passing, as users could potentially manipulate view output by crafting specific argument values