Drupal is a registered trademark of Dries Buytaert
Menu Per Role 8.x-1.9 Minor update available for module menu_per_role (8.x-1.9). AI (Artificial Intelligence) 1.5.0-alpha1 First alpha version released for module ai (1.5.0-alpha1). Easy Encryption 1.0.4 Minor update available for module easy_encryption (1.0.4). Soccerbet 1.1.15 Minor update available for module soccerbet (1.1.15). United Nations Maps & Geoservices 3.0.8 Minor update available for module unep_maps (3.0.8). Burndown 1.0.71 Minor update available for module burndown (1.0.71). Bible 3.4.1 Minor update available for module bible (3.4.1). Bible 3.4.0 Minor update available for module bible (3.4.0). Menu Per Role 2.0.0 Module menu_per_role updated after 7 months of inactivity (2.0.0). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module allows you to show different field layouts for content based on configurable rules without writing any code. It's useful for scenarios like displaying a teaser to anonymous users and a full article to subscribers, by switching the entity's display mode at render time based on conditions like user roles or other criteria.

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
2 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

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