Views display

A display is one output of a Drupal View, such as a page, a block or a feed. One view can hold several displays that share or override settings.

Learn DrupalDrupal glossary

A display is one way a Drupal View delivers its results: as a page with its own URL, as a block you place in a region, as a feed, and so on. One view can have several displays. They start with the same settings, and each display can override a section such as the title, the pager, the filter criteria or the sort criteria.

How displays work in Drupal 11

The Drupal User Guide says that each view can have one or more displays, and each produces one type of output. Core registers them as display plugins that extend DisplayPluginBase:

  • Page (page): the view as a page with a URL and menu links.
  • Block (block): the view as a block.
  • Feed (feed): the view as a feed, such as an RSS feed.
  • Attachment (attachment): a secondary display attached to a primary display, so one view can show several lists. Its attachment_position option can be before, after or both, and its displays option holds the parent displays; the list is empty until you choose one.
  • Embed (embed) and Entity Reference (entity_reference), which are also in the Views module. The REST module adds REST export.

Behind them sits a display with the ID default, which holds the fallback settings. The Views UI hides it unless you tick Always show the default display under Structure › Views › Settings. In DisplayPluginBase, a defaults option marks each overridable section as inherited from the default display, until an override copies the values. The section names include title, pager, fields, filters, sorts, relationships and arguments (the contextual filters). Every display also gets its own ID, such as page_1 or block_1.

In the dialog for a setting, the For list chooses the scope. All displays changes the shared value; This page (override) or This block (override) changes only the display you are on.

Example

A news view has a page display with the path news that lists ten items. You add a block display and, in its dialog, choose This block (override) for the pager and set five items. You place the block through Structure › Block layout. The page keeps its ten items, because only the block overrides the pager. The Drupal User Guide builds a recent-recipes block this way.

In custom code, render a display with the view element:

$build = [
          '#type' => 'view',
          '#name' => 'news',
          '#display_id' => 'block_1',
        ];

Common mistakes

  • Editing with All displays selected. A change meant for the block then also changes the page.
  • Confusing display and format. The format (table, grid, list) is a setting inside a display; it does not choose the output type.
  • Expecting a block to have an address. A path and menu link belong to the page display; the block display only produces a block.
  • Still using views_embed_view(). It is deprecated since Drupal 11.4.0 and replaced by the render element shown above.

For marketing and content teams

Ask for one view with several displays instead of copies of the same view. A "Latest news" block on the homepage and a full news page can share their filters, so a rule such as "only published articles" is changed once. Name the displays in a way editors can recognize, because the display title appears wherever someone picks it.

With DXPR

In DXPR Builder, the Drupal Views tab lists every display of every enabled view, page displays included, as "View name (Display title)". A block display is the usual choice, because it has no page of its own. See DXPR Builder.

Sources

Questions about Views display

The display decides where the results go: a page, a block, a feed. The format decides how the rows look inside it, for example a table, a grid or an HTML list.

Displays inherit their settings from the view's default display until you override a section. When you edit a setting, the For list offers All displays or an override for the current display. Choose the override to change only this display.

Use the render element. Since Drupal 11.4.0, views_embed_view() is deprecated; build an array with #type set to view, plus #name and #display_id, and Drupal renders that display.

Related terms

All Drupal terms from A to Z