Creating view modes
Drupal view modes are used to display different views of content. For example, the Full view mode is typically used to display the content in full on its own page whereas the Teaser view mode is used to display a short version of content within lists.
Drupal provides a number of default view modes including:
- Full content - Typically used to display content in full on its own page
- Teaser - Typically used to display content in short form on lists.
- Search index - Used to display content as part of a website search result
- RSS - Used to define which content is provided through an RSS feed.
Creating new view modes
To create a new view mode:
Step 1 - Create a new view mode
- Navigate to Structure > Display modes > View modes > Add new view mode
- Click on the type of content you want to make a view mode for. Choose Content for Content types.
- Give your View mode a short but descriptive name. You will use this name later to identify the View mode when you create a template for it.
Once you've saved your new View mode it will appear in the list of View modes under Structure > Display modes > View modes
Step 3 - Select the fields you want to display in your view mode
Once you have created your new View mode you can select which fields it should display.
For the purpose of an example, the following steps are for managing the fields your new View mode will display on the Article content type. The same process applies for all other content entity types.
To manage the fields:
- Navigate to Structure > Content types > Article > Manage display. You will see a number of View modes at the top of the page. These probably include Default, RSS and Teaser. Your new view mode will not be there so you need to add it.
- Scroll to the bottom of the screen and click and open the Custom display settings expandable area
- Click the checkbox next to the name of your new view mode
- Click Save
Once you've enabled the View mode within Manage display, you can select which fields it will use:
- The page will refresh and your view mode will appear at the top as an option
- Click on your view mode to show the fields it includes
- Select the fields you want to include and those you want to exclude:
- Drag fields you want to include into the active area (Top of list)
- Drag fields you want to exclude into the disabled area (Bottom of list).
- The fields you place in the active area will be available to your templates for that view mode
- Click Save.