How do I switch back to default view mode?

Created on 10 March 2023, almost 2 years ago
Updated 12 September 2023, over 1 year ago

Problem/Motivation

I see all the custom view modes that I have created but I do not see the "default" view mode.

How can I select the "default" view mode in configuration for the field?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States SocialNicheGuru

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @SocialNicheGuru
  • πŸ‡©πŸ‡ͺGermany hctom

    Hi @SocialNicheGuru, thanks for your request. Can you please outline the use case for this a little more? Because in my understanding, the default view mode should always be treated as a fallback view mode that is used, if there is no specific view mode configured or a requested view mode does not exist anymore.

    Another option might be to create a custom "default" view mode, that you can use in all view mode switch fields to switch to a generic representation of an entity, while preserving the system's default view mode fallback functionality.

  • πŸ‡ΊπŸ‡ΈUnited States callinmullaney

    @hctom I think I'm having a similar issue to the one described above. The selected view modes are not available on the field edit page. There is a `View modes allowed to switch to` field that is set to required but there are no options to select any and the default value select list is empty and only says `-no-change-`.
    Using the most recent version of Drupal 9.5.x and the latest version of the module you should be able to do the following to reproduce.
    1. Create a paragraph with 3 view modes. default, custom_a, custom_b and make sure they are enabled for said paragraph.
    2. Add the view_mode_switch field to the paragraph and select either all view modes or just the custom ones on the field_settings page.
    3. On the following field_edit page the previously selected view_modes are not available in the default field value section. Attempting to save the field_settings page results in a drupal message of " View modes allowed to switch to field is required. "

  • πŸ‡©πŸ‡ͺGermany hctom

    @callinmullaney thank you for your detailed issue description. If I understand you right, you are enabling all your view modes in the field storage settings form and do not see them in the field instance settings anymore, right?!

    I guess I have to rework the UI texts a little to make them better understandable ;) But I'll try to (hopefully) clarify this a little more with an example:

    Let's assume, you have a paragraph type "Image + Text" and you want to be able to display this paragraph type in 3 different variants: Image above text, image to the left of the text, image to the right of the text. All these three custom view modes are created and their corresponding displays are configured for the "Image + Text" paragraph type.

    In order to be able to switch to those view modes, you then add the view mode switch field to the paragraph type.

    In the field storage settings, you only configure the "View modes to switch", meaning the view modes that may be switched by the field, when requested to render. In this example, this may only be "Default" (or whatever view mode you are using to render paragraphs in your embedding content). Maybe you also want to switch the "Preview" view mode with this field as well (e.g. to have a live preview of the view mode switch in the backend). If so, check the "Preview" view mode, too - the view mode switch field will then handle switching display output whenever the "Default" or the "Preview" view modes are requested to render (of course only if an editor has set a view mode to switch to). All configured view modes in the field storage settings form are now treated as ORIGIN view modes. Just think about them as a switchable placeholder slot which may even provide a default display variant, if the view mode switch field is not set to be required.

    In the field instance settings you have to configure the "Views modes to switch to", meaning the target view modes that the view mode switch field switches the display output to, if selected by an editor. In this example, those would be "Image above text", "Image to the left of the text" and "Image to the right of the text". All configured view modes in the field instance settings form are now treated as TARGET view modes. With this approach, the view mode switch field should be required, so the "- No change -" option is not available, which would lead to rendering the paragraph in the requested ORIGIN view mode ("Default", "Preview").

    The "Default" view mode is never available in the field instance settings form as TARGET view mode, because it should always be treated as the fallback for any requested view mode that may not be available anymore. Additionally, in the field settings you are not able to select any view modes that you already configured as ORIGIN view modes for this field. This is because there is no reason to allow to e.g. switch a "Custom A" ORIGIN view mode to a "Custom A" TARGET view mode because they are already the same.

    The ORIGIN and TARGET view modes are configured separately, so you are able to reuse a field switching a specific set of ORIGIN view modes (field storage config, which is always global for a field everywhere it is used), but use different TARGET view modes (field instance config) per implementing bundle.

    Does this help or even solve your problems? Or did I get you completely wrong? ;)

  • πŸ‡©πŸ‡ͺGermany hctom

    Hi @SocialNicheGuru and/or @callinmullaney, do you have any feedback for me? Otherwise I will close this issue, because without feedback it is impossible to work on this potential issue.

  • πŸ‡©πŸ‡ͺGermany hctom

    Closing this for now, due to lack of feedback.

  • Status changed to Closed: works as designed over 1 year ago
Production build 0.71.5 2024