- 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語言程序設(shè)計(jì)
- Vue.js 3.x從入門到精通(視頻教學(xué)版)
- Django:Web Development with Python
- 21天學(xué)通C++(第6版)
- Hands-On C++ Game Animation Programming
- 精通Python自然語言處理
- 重學(xué)Java設(shè)計(jì)模式
- 速學(xué)Python:程序設(shè)計(jì)從入門到進(jìn)階
- Learning Apache Karaf
- Mastering Apache Storm
- Python 3 Object:oriented Programming(Second Edition)
- 和孩子一起學(xué)編程:用Scratch玩Minecraft我的世界
- AngularJS UI Development
- 可視化H5頁面設(shè)計(jì)與制作:Mugeda標(biāo)準(zhǔn)教程
- C語言從入門到精通(視頻實(shí)戰(zhàn)版)