Introduction
Drupal is among the top Content Management Systems (CMSs) across the globe, alongside Joomla and WordPress. The process of creating views in Drupal version 8 is similar to the one for Drupal 7. The only difference is that Drupal 8 has incorporated the Views module. It is automatically installed once you install Drupal 8 core.
Views feature allows the user to display pieces of content on their website in any format. The pieces of content include comments, nodes (articles, basic pages, or blog posts), taxonomy terms (tags or labels), and user profiles.
This tutorial will take you through the steps involved in creating views in Drupal 8.
Let’s start.
Step 1: Finding Views
- To get started with views, check the Article content type by navigating to the admin dashboard, then go to the Structures section and click Content Types. Or follow the path – “admin/structures/types.â€
- The next thing is to locate the fields connected to the Article content type. To do so, follow the path (admin/structure/types/manage/article/fields) or go to the admin dashboard again, locate Structures, click the Content Types icon. Then go to the Manage Fields and press Articles, before clicking the Fields section.
- To add your content, follow the path – “node/add/article†or go to the admin section, click the +Add Content button, then the Article link.
- Once you’ve added your content, the view page will be present in the node teaser, and it should look like this:
Step 2: Creating a View
- To start, navigate to the Manage page and press the Structure tab (admin/structure).
- To create an entirely new view, select the Views link on this page. You will be taken to Views Configuration page. You can also follow the path: admin/structure/views.
On this window, you will notice a slight difference in style layout from the previous Drupal version 7 Views configuration page. By default, there is a wide list of views. Based on your needs, you can choose to edit or duplicate and use these views. You can also create a new view by pressing the Add view button. - The illustration below shows how to edit or duplicate a current view. Drupal 8 Duplicate feature is similar to Drupal 7 Clone feature.
- Before we start creating a new view, let’s look at some details about Views and Advanced View settings.Navigate to the Basic section if you want to configure the basic settings (path: admin/structure/views/settings). In this case, you can choose what to display and set it at default, or view the SQL queries in the current view.
You can access the cache settings by clicking the Advanced section. This is one of the new features in Drupal 8. - Let’s create a new view to list the content type in the view. Use the path – “admin/structure/views/add†or go to the admin section, look for the Structure section, then go to the Views section, and click on the Add view button.You will be presented with a page prompting you to fill in the View name field. For this example, we will use the Article list as our view name. Also, enter the details for the s Show and Of type. We have selected Content and Article respectively for these two fields.Then click the Save and edit button.
- You will be taken to the Article list page.
Here, you need to edit and change the setting Show to Content. To do so, press Show: Fields icon under FORMAT. A popup box will appear as shown below:
On this page, choose Content, then click Apply. Another popup will appear prompting you to clarify the View mode you prefer. From the drop-down menu, select Teaser and then click the Apply button. - This will take you to the Master display page. For the current view, add an extra page for the display then press the +Add section just after the Master icon. Now, choose Page from the drop-down.
Your page display will be added to your current view automatically.If you look closely at the Page button, you will notice it has a red-colored border. This indicates that there are authentication errors.
At this point, set a Path for your page display. Set it under the PAGE SETTINGS. Go to the Path: No Path is set section. You will see a popup that will allow you to indicate the path to present your current view.
On the popup, enter the path article/list, then press the Apply button. - You will be taken to the views page. Press the Save button to apply these changes. Once you have saved your view, go to the article/list. Here, you will see your article list displayed on your view page. You should see the following:
Conclusion
That’s it! You can now go ahead and create entirely new views in Drupal 8. If you run into problems while creating a view in Drupal, don’t hesitate to contact us for further assistance.
Check out the top 3 Drupal hosting services:
- Click this link and all your queries to best hosting will end.