Skip to content

Recipes and Drush

Config actions

Overrides are config entities, so the display actions of core work on them. The action IDs use the config prefix theme_view_display.display.

Action Does
entity_create:createIfNotExists Creates the override. The theme, entity type, bundle and view mode are read from the config name when you leave them out.
entity_method:theme_view_display.display:setComponent Places a component.
entity_method:theme_view_display.display:hideComponent Hides a component.
entity_method:theme_view_display.display:setThirdPartySetting Sets a third-party setting.
entity_method:theme_view_display.display:enable, disable, setStatus Changes the status.

Inside a recipe, the short form works:

config:
  actions:
    theme_view_display.display.olivero.node.article.teaser:
      createIfNotExists:
        status: true
      setComponent:
        name: body
        options:
          type: text_default
          weight: 3
      hideComponent:
        name: links

Actions that take no argument, such as disable, take an empty map: disable: {}.

Creating an override from a view display

createThemeOverride is applied to the core view display to copy. It creates the override for a theme from that display.

config:
  actions:
    core.entity_view_display.node.article.teaser:
      createThemeOverride:
        theme: olivero

The value is a theme name, or a map:

Key Default Meaning
theme required The theme. It must be installed.
fail_if_exists false When true, an existing override is an error. Otherwise it is left as it is.
status true Whether the override is active.

The override is a copy of the fields, hidden components and third-party settings of the display, so Display Builder and Field Group data come with it. The action fails when the theme is not installed, the theme is missing, or the target is not an entity view display. To start from another override, use the Add form.

The theme must be installed before this action runs, so install it earlier in the recipe.

Shipping overrides

Overrides are plain config entities with full dependencies, so config export and import move them like any other display. The theme and the core display they depend on import first. One file per override keeps merge conflicts to one theme and one display.

Drush

drush theme-view-display:list

Lists every override with its status and its theme and module dependencies. Alias: tvd-list.