Module Description
This module provides a View mode switch field type allowing content editors to change specific view modes when editing an entity.
Common use cases
* You have an entity like a Paragraph (or any other fieldable entity type) which may be displayed in different variants (e.g. an "Image + text" paragraph that may be outputted with the image on the left, right or even above the text). With this field added to the entity and all appropriate view modes configured, content editors will be able to decide which view mode to use when displaying the entity.
* You have entity listings where you want to be able to highlight specific items by using a different view mode for them.
Features
* Both the origin view mode(s) and the view mode(s) allowed to switch to are configurable per field. You may even change these settings later, when there are already values available for a field.
* A single View mode switch field may be used to apply the same view mode for one or more view modes (e.g. control the view mode to use for "Full" and "Preview" view mode simultaneously). If different origin view modes should be switched differently, just add any number of View mode switch fields to handle those separately.
* View mode switches may be chained! Before outputting a view mode, it is always checked, if there is another field requesting a switch for that view mode (with recursion detection).
* The site's status report informs about any misconfigured View mode switch fields (e.g. when all origin view modes were removed, that have been associated to a field).
* Even though view mode switching happens "behind the scenes" with hook_entity_view_mode_alter(), it is also possible to output the field value via Field UI (e.g. for administrative previews) - either the view mode's machine name or its human-readable label.
* Supports displaying field value differences between revisions via Diff module.
* All code is thoroughly tested and automated tests are available for all functionality.
Similar modules
* View Mode Selector (similar approach, but it only allows to switch a special view_mode_selector view mode)
Common use cases
* You have an entity like a Paragraph (or any other fieldable entity type) which may be displayed in different variants (e.g. an "Image + text" paragraph that may be outputted with the image on the left, right or even above the text). With this field added to the entity and all appropriate view modes configured, content editors will be able to decide which view mode to use when displaying the entity.
* You have entity listings where you want to be able to highlight specific items by using a different view mode for them.
Features
* Both the origin view mode(s) and the view mode(s) allowed to switch to are configurable per field. You may even change these settings later, when there are already values available for a field.
* A single View mode switch field may be used to apply the same view mode for one or more view modes (e.g. control the view mode to use for "Full" and "Preview" view mode simultaneously). If different origin view modes should be switched differently, just add any number of View mode switch fields to handle those separately.
* View mode switches may be chained! Before outputting a view mode, it is always checked, if there is another field requesting a switch for that view mode (with recursion detection).
* The site's status report informs about any misconfigured View mode switch fields (e.g. when all origin view modes were removed, that have been associated to a field).
* Even though view mode switching happens "behind the scenes" with hook_entity_view_mode_alter(), it is also possible to output the field value via Field UI (e.g. for administrative previews) - either the view mode's machine name or its human-readable label.
* Supports displaying field value differences between revisions via Diff module.
* All code is thoroughly tested and automated tests are available for all functionality.
Similar modules
* View Mode Selector (similar approach, but it only allows to switch a special view_mode_selector view mode)
Module Link
Project Usage
882
Security Covered
Covered By Security Advisory
Version Available
Production
Module Summary
This module solves the issue of allowing content editors to change specific view modes when editing an entity.
Data Name
view_mode_switch