Drupal is a registered trademark of Dries Buytaert
drupal 11.3.8 Update released for Drupal core (11.3.8)! drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! video_embed_field 3.1.0 Minor update available for module video_embed_field (3.1.0). bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). commerce 3.3.5 Minor update available for module commerce (3.3.5). geocoder 8.x-4.34 Minor update available for module geocoder (8.x-4.34). leaflet 10.4.5 Minor update available for module leaflet (10.4.5). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3).

Display Mode Switcher lets you show different field layouts to different audiences - no templates, no custom code, just configuration.

The classic use case is a paywall: anonymous visitors see a teaser or locked version of content, while subscribers see the full article. But the module works for any scenario where different users (or different contexts) should see a different arrangement of fields.

You define rules that specify: which entity and display mode you are starting from, which display mode to switch to, and what conditions must be true for the switch to happen. At render time the module evaluates your rules in order, picks the first match, and swaps the display mode transparently. If no rule matches, the original display mode is used unchanged.

Drupal's render cache is fully respected: cache metadata from every evaluated condition is propagated to the rendered output automatically.

Features

  • Switch any entity's view mode at render time based on configurable rules - no template overrides needed.
  • Rule-based evaluation with weight-ordered priority: the first matching rule wins, making it easy to build subscriber/anonymous/admin hierarchies.
  • Ships with a User has role condition out of the box. All standard Drupal core condition plugins (node type, language, request path, current theme) work automatically.
  • Any contrib module that provides condition plugins is supported automatically - no extra wiring.
  • Custom condition plugins can be added by any module via a simple PHP class and a config schema entry.
  • Conditions receive the entity being rendered directly, so field-level checks (e.g. "is this node marked as paywalled?") require no Context API setup.
  • Cache tags, cache contexts, and max-age from all evaluated conditions are merged into the render array automatically.
  • Rules are standard configuration entities: fully exportable, deployable via drush config:export/import, and version-controllable.
  • A single permission (administer display mode switcher) controls access to rule management.

Post-Installation

After enabling the module:

  1. Create the view mode you want to switch to. Go to Structure → Display modes → View modes, add a new view mode for your
    entity type (e.g. paywall), then go to the entity type's Manage display page, enable the new view mode under Custom display
    settings
    , and configure which fields it shows.
  2. Create a rule. Go to Structure → Display modes → View modes → Switcher rules
    (/admin/structure/display-modes/view/switcher) and click Add rule. Choose the entity type and (optionally) bundle, set the source
    display mode that triggers evaluation (e.g. full), set the target display mode to switch to (e.g. paywall), and add one or
    more conditions. A rule with no conditions always matches — useful as a catch-all fallback at a high weight.
  3. Test. Render the entity in the source display mode as a user who meets the conditions and verify the correct display mode appears.
    Then test as a user who does not meet the conditions.

No database updates are needed. All configuration lives in YAML files and can be managed with Config Management (drush config:export).

Additional Requirements

  • Drupal 11.3 or later
  • No additional module dependencies beyond Drupal core.

Similar projects

  • View Mode Page - serves an entity under a custom URL using a specific view mode,
    rather than switching modes conditionally at render time.
  • Display Suite - powerful field layout builder that works well alongside this module; it does not provide rule-based mode switching.
  • Content Access / href="https://www.drupal.org/project/permissions_by_term">Permissions by Term - restrict access entirely rather than showing a degraded view to unauthorised users. Use Display Mode Switcher when you want a teaser or locked layout instead of an access denied page.

Activity

Total releases
1
First release
Apr 2026
Latest release
12 hours ago
Release cadence
Stability
0% stable

Releases

Version Type Release date
1.x-dev Dev Apr 21, 2026