- Drupal 8 Blueprints
- Alex Burrows
- 465字
- 2021-07-03 00:03:27
Understanding views
Now that we have set up our first view, let's get it to display some content.
We will create a latest news block, which will show our latest five news posts. By default, the view will display any content that is related to the content type, and it will only show the title. We will change this:

In Fig 1.20, we can see there are three columns and in each column, there is an individual section. For now, we will just go through what we need for our Latest news block, but later we will go into more depth.
In views, we have Displays, these are the different ways that content is displayed. For the latest news and related news, we will, however, use the Display type of block. We will go into more detail later when we build our news listing page:
- TITLE: This is the title that will appear in our display.
- FORMAT: This is split into two sections:
- Format: This is, by default, the type of layout, along with settings, for this format.
- Show: This allows us to define how we want the content to be shown; we can either show based on a view mode or add fields to the view display.
- FIELDS: If we select the mentioned Format type to be fields, we will be able to add fields from our content type into this display. This allows us to customize our fields and how they are shown, and it ignores our view mode we created earlier.
- FILTER CRITERIA: We can set different filters that will depend on what content is to be shown. By default, Published is set to Yes.
- SORT CRITERIA: We can sort our content to display in many ways.
This is the first part we will cover. We want to create a very simple block that uses our default teaser view mode. To do this, we must click on the value next to Show; in this case, its Fields.
When we do this, a modal will appear with three radio buttons:

From Fig 1.21, we want to select Content. After we click on Apply, we will be shown a drop-down list that contains all the types of view modes we can have. We want to select the Teaser view mode.
When we apply this, we will see our news article along with its title, post information (author and timestamp of when it was created), and our Read more link in the preview. We see the post information because we had Show submission information checked inside the content type settings. Now that we have created our first view, let's place it on our sidebar.
- Java 9 Concurrency Cookbook(Second Edition)
- PyTorch自動駕駛視覺感知算法實戰
- Java Web應用開發技術與案例教程(第2版)
- Python高效開發實戰:Django、Tornado、Flask、Twisted(第3版)
- PHP+MySQL網站開發項目式教程
- 利用Python進行數據分析
- Android驅動開發權威指南
- C# and .NET Core Test Driven Development
- Java程序員面試筆試寶典(第2版)
- Python Data Science Cookbook
- Java Web應用開發項目教程
- Learning Ionic
- 數據科學中的實用統計學(第2版)
- 算法超簡單:趣味游戲帶你輕松入門與實踐
- Developing Java Applications with Spring and Spring Boot