This project is not covered by Drupal’s security advisory policy.

Views Block View Mode lets you choose a different view mode for each placed Views block, so one view can show items as small cards in one place and as large teasers in another, without copying the view.

In Drupal, a view that lists content (for example "Recent articles") renders each item using a view mode, such as Teaser or Full content. Normally that view mode is fixed in the view, so every block made from that view looks the same. If you want a different look somewhere else, you have to duplicate the view. This module removes that need: the view mode set in the view becomes the default, and each block placement can override it.

Features

  • Adds a View mode select list to the configuration form of Views blocks, in the regular Block layout and in Layout Builder.
  • Opt-in per view display: site builders decide which block displays allow the override, using a new Select view mode checkbox under Block settings > Allow settings.
  • Works with any entity row style (Content, Taxonomy term, User, Media, and so on). All view modes of that entity type are offered.
  • Optional Display Suite support: if Display Suite is installed, the option also works with the Display Suite: Content row style. Display Suite is not required.
  • Leaving the option on - View default - keeps using the view mode set in the view.
  • Safe fallback: if a chosen view mode is later deleted, the block falls back to the view's view mode instead of breaking.
  • Builds on Chaos Tools Views (ctools_views), so all of its block options (items per page, offset, pager, hide/sort fields, and so on) keep working alongside the view mode option.
  • Fully configuration-exportable: the choice is stored in the block configuration with a proper config schema.

Example use case: an Article content type has the view modes Small, Medium and Large. Editors place one "Recent articles" Views block on many pages with Layout Builder and pick the view mode that fits each spot: Large on the homepage hero, Small in a sidebar, Medium on landing pages. There is one view to maintain instead of three.

Post-Installation

The module has no settings page. It adds an option to Views block displays:

  1. Edit a view (Structure > Views) and add or select a Block display.
  2. Set Format > Show to Content, Display Suite: Content, or another entity row style, and pick the default view mode in its settings.
  3. Under Block settings > Allow settings, enable Select view mode, then save the view.
  4. Place the block in Structure > Block layout, or add it in Layout Builder.
  5. In the block form, choose a view mode, or leave it on - View default -.

Notes:

  • The option only appears for displays that render entities. It does not appear for Fields row styles.
  • With the Display Suite: Content row style, the Display Suite options Alternating view mode, Use the advanced view mode selector and Use view mode of display settings choose a view mode per item, so they take priority over the block's view mode where they apply.
  • Only one module can replace the Views block display class. If another module (other than ctools_views) also replaces it, this module leaves that class alone and the option is not shown.
  • Block displays created before ctools_views was enabled may not show the extra Allow settings options. Add a new block display if that happens.

Additional Requirements

  • Drupal 11.1 or later.
  • Views and Block (Drupal core).
  • Chaos Tool Suite (ctools) 4.1 or later, with its Chaos Tools Views (ctools_views) submodule enabled.
  • Layout Builder (Drupal core): editors can place the same Views block many times per layout and choose a view mode for each placement, which is where this module is most useful.
  • Field UI (Drupal core): to create and configure your own view modes (Structure > Display modes > View modes).
  • Display Suite (optional): the view mode option also works with its Display Suite: Content row style.

Similar projects

  • Chaos Tools Views (ctools_views): lets each block override items per page, offset, pager, fields and sorts, but not the view mode. This module adds the view mode option on top of it.

Supporting this Module

Development was supported by 3P Technologies.
Bug reports, patches and feature ideas are welcome in the issue queue.

Community Documentation

Supporting organizations: 
Initial building, ongoing maintenance and development

Project information

Releases