View item element
The View items are the individual results (Rows) returned from the View. The layout of the View items are not created directly within the View template because they reference View modes which have their own View mode templates. For example, you can reference the Teaser view mode as your View item and create a template for the teaser.
You can also use the View item element to render Fields rather than View modes. For more information, see the section below Rendering fields.
Locating the view item element
To find the View item element:
- Navigate to Site Studio > Templates > View templates
- Create or Edit a View template
- Click the + button on the Layout canvas
- Within the Elements tab, look for the View item element.
The View item element includes the following fields:
Within your Site Studio view template you can select the view mode to use for the view results. If you select the view mode within the view template, this will override the view mode selected within your Drupal view settings. If you want to use the view mode selected within your Drupal view settings you need to select Drupal view default within the View mode drop down.
- Entity type - Select the entity type you are displaying within your view
- Bundle - Select the bundle your are displaying
- View mode - Select the View mode to use for the display. Select Drupal view default to use the view mode selected within your view.
Using multiple view modes. Some views display results from multiple entity types and bundles. For example, search results. When displaying multiple entity types or bundles, you can use Site Studio to choose which display view mode to use for each.
- Add comments - Add comments to the Element. For more information, see Adding comments to an element.
You can use the View item element to render Fields rather than Content view modes. The View item will render the Fields using their field formatters. To style or layout the fields, you can place the View item within a Basic container element and apply styles that target helper classes provided by the field formatters.
To use fields rather than content:
Step 1: Configure your view
- Within your Drupal view settings, within the Format > Show section, select Fields
- Add the fields you want to render within the Fields section.
Step 2: Configure your view template
To stop your View template from rendering Content view modes, you must remove the View mode section from the View item element within your template.
- Within your Site Studio view template, click on the View item element to edit it's settings
- Within the settings, click on the Properties button and select Settings within the menu
- Click on View mode to deselect it. This will remove it from your View item element
- Click Apply and save your View template.
Your View template will now use the Format settings provided by your View.