Drupal is one of the top 3 Content Management Systems (CMSs) in the world, along with WordPress and Joomla. Drupal 8 is currently the latest version of Drupal.
Views is arguably the most powerful module of Drupal, because it allows us to display any pieces of website ‘content’ in any format. The content that Views allows us to show are entities, such as:
- Nodes (content such as basic pages, articles, or blog posts)
- Comments
- Taxonomy terms (such as the ‘labels’ or ‘tags’ that can be given to content)
- User profiles (people who can log into the website)
Thus, to understand this article, you should understand what entities are in Drupal, and how entities are made up of fields.
Please note: This article should not be considered accurate or complete until Drupal 8 has been released, and this article has been updated accordingly.
Part 1
Part 1 of 3:
Creating a View
-
Go to the Views page. Log into your Drupal site, and select ‘Manage’ > ‘Structure’ > ‘Views’.
-
Add a new view and choose its initial setup.
- Click the ‘Add new View button.
- Fill in the view’s name; this is only used administratively (you’ll see this in the administration pages, but not on the actual website).
- Add a description if the name of the view doesn’t clearly imply what it’s for or how it’s structured.
- Under ‘View settings’, you can choose what kind of entities (and which kind of content if you choose a content entity) you’d like the view to display. This cannot be changed once you save the view. The entities that are displayed are called the results, just like search results.
Note that anything you choose or write on this ‘Add new view’ page (except the entity type) can be changed at any time after you save this view.
-
Choose a display mode: whether this view should display a page, a block, or both. If the view will be displaying lots of information or content, it should have a page. If it won’t be displaying a lot of content, and you’d like to place it in a region (see managing Drupal blocks or building Drupal themes to learn about regions) on particular webpages, then choose a block. There are other view modes that can also be chosen after you save the view, such as an RSS feed.
-
Choose the title and layout. If you’d like the page or block title to be different from the view’s name, you can change it. Under ‘Page/Block display settings’, choose layout you’d like the results to have:
- A grid is a large table, where each result has its own cell
- An HTML list is a ‘unordered’ bullet-point list
- A table displays each result as a row, and each field of each result in its own cell
- An unformatted list is the simplest layout, with each result below the previous result.
-
Choose the display format and other settings. The ‘of’ selection box lets you choose the display format (such as full posts or teasers) you’d like to use, or specific fields. The display formats can be configured in the entities’ settings (such as on the ‘Structure’ > ‘Content types’ pages for content). Choose the fields option if you’d like to choose exactly which fields you’d like to display (such as ‘titles’, ‘creation date’, and many others), and each field’s settings.Advertisement
Part 2
Part 2 of 3:
Editing Settings
-
Get familiar with the view editing screen. When you’ve saved the view, or when you edit an existing view, you’ll see a screen with the name of the view (and the type of entity that displays) at the top. The top half of this screen, titled ‘Displays’, is where you can change almost anything about the view. The bottom half is where a preview of the results will be shown, and will be updated as you change view settings.
- In this results area, at the top, the area with the text ‘Preview with contextual filters: ’ and the textbox and the ‘Update preview’ button are only useful if you add contextual filters (explained below); if you view doesn’t use these, ignore this area.
-
Check the basic settings. Under the ‘Displays’ title, you’ll see a button for each display type that your view has (blocks and pages). If you click the ‘Add’ button, you’ll see several new types of displays. Below this, you’ll see the name of the selected display type; you should rename the display if you have more than one of the same kind (for example, you have two blocks; one with a grid layout, the other with a table layout). Below this, there are 3 columns (although the third one, ‘Advanced’, is minimized initially). The first column shows you settings you chose when you created the view and saved it. At the bottom are the FILTER and SORT CRITERIA. Filters allow you to restrict which entities will show in the results. For instance, by default for ‘content’ views, there will be a filter that only allows published content to show. Sort criteria are self-explanatory. Both filters and sorts can be ‘exposed to visitors’, which means that anyone viewing the page will be able to adjust the filter or sort criteria, which is particularly valuable for large views with lots of content. You’ll see these ‘exposed criteria’ just above the results (in the results preview area at the bottom of the page).
-
Configure the display type-specific settings. The first group of settings in the middle column is specific to the display type you’ve chosen. For instance, for pages, this is where the URL of the view can be changed. This is also where the setting to allow or deny particular users seeing the view (like permissions) is.
-
Add a header or footer to provide additional information. Below the display type-specific settings, you can add a header and footer (or more than one of each) to the view. The commonly-used options are Global: Text area and Global: Result summary. The Result summary displays information about the results of the view, such as how many results are currently displayed. Other options are to add another entire view, or an entire entity (such as a page), into the header or footer.
-
Provide no-results behaviour to reassure the viewer. When a view isn’t configured correctly, or when there aren’t any of the expected entities to show, there won’t be any results. It’s helpful to both the visitor and you (administers) to know when this happens, in order to know the view is there, but isn’t working as expected (or there’s missing content). Adding a no-results behaviour is almost exactly the same as adding a header or footer, except that it shows up where the results would have been displayed.Advertisement
Expert Q&A
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
About this article
Thanks to all authors for creating a page that has been read 35,111 times.
Advertisement