官术网_书友最值得收藏!

  • Drupal 8 Blueprints
  • Alex Burrows
  • 366字
  • 2021-07-03 00:03:27

Displaying content with views

Prior to Drupal 8, you would have to download a variety of contrib to use view; however, views is now in Drupal core!

Now that we already have the power of views within, let's go create a view.

Views is used to display content, and can allow us to sort our content in an easy way, therefore reducing the need of custom modules.
Fig 1.19: Views admin page

If we now go to Structure | Views, we will see a page listing content already as per Fig 1.20. These are our default views that are part of Drupal core; we can modify them as much as we like. Now, let's create our very first view. For people new to Drupal, views can be very scary and confusing. We won't be afraid, so let's create our Related news view.

At the top of the page, you will see + Add view; by clicking on this, it will in fact allow us to create a new view. So, let's go ahead and do that now. We can see various fields on this page, but don't worry, we will go through each field now:

  • View name: User-friendly name for our view. Drupal will create a machine name from this, which allows us to access when we try to alter it with code.
  • Description: This description will appear on the Views admin page; it is more of a helper to other developers to explain what the view does.
  • View settings:
    • Show: We can select what type of entity we want to show, depending on which we will change the options next to this field.
  • Tagged with: This allows us to filter by tags on the Views admin page.
  • Sorted by: We can order our content in views.
  • Page settings: If we want to create our view with a page first, we can do that, and we can also add some basic settings for the page; click on the Create a page checkbox, and you will see a whole bunch of fields to enter.
  • Create a block: We can add blocks to content, and views allows us to create these to display our content.
主站蜘蛛池模板: 钟祥市| 崇信县| 蓝田县| 英超| 蒙城县| 农安县| 奉化市| 冕宁县| 邢台县| 哈尔滨市| 盘山县| 南丹县| 双柏县| 文水县| 榆中县| 唐河县| 沙湾县| 赣州市| 鹿邑县| 安康市| 镇坪县| 张家界市| 无锡市| 克东县| 武鸣县| 襄汾县| 卢龙县| 榕江县| 墨竹工卡县| 平江县| 尚志市| 遂平县| 页游| 昌平区| 集贤县| 桓台县| 应用必备| 商城县| 太白县| 曲阜市| 察隅县|