The Views module lets even non-developers organize and present the website's content in the desired ways. Website administrators love it, Drupal newbies start with it, and Drupal ninjas perform miracles with it. No wonder it used to be the most downloadable contributed module. Well, it still is — in Drupal 7. But, with the arrival of Drupal 8, it got an even higher position — the Views became part of Drupal 8 core, so it no longer needs to be downloaded separately. The Views “inside Drupal” is listed among Drupal 8’s best improvements. Let’s discover a couple of special capabilities of the Views that will let you enhance your Drupal 8 website.
The Views: a true behind-the-scenes architect for websites
Lists, graphs, maps, tables, blocks, calendars, comments, contact forms, photo galleries and carousels, blog posts… The Views module shapes all this and much more with the data it fetches from the database. It looks attractive!
However, despite the name, the essence of Views lies much deeper than the attractive content presentation. Its behind-the-scene work is priceless. The module lets you not just list your entities, but also filter and sort them in all kinds of ways, change attributes, create relationships, and give or deny user access. The Views caches the data to improve your website’s performance. The list could go on. Here are a few examples of its special capabilities.
Some special ways to use Views on your Drupal 8 website
Views and REST export
Setting up REST API export with Views is easier in Drupal 8 thanks to built-in web services like Serialization, RESTful Web services, HTTP Basic Authentication, and HAL. They need to be enabled.
The “Provide REST export” field is already included into the Views setting form and just waits for you to check it.
Using Views with a third-party data store
Your Drupal website’s “classic” SQL database is far from being the only possible data store for the Views. There are useful data source plugins ready for Drupal 8 — Views XML Backend, EntityFieldQuery Views Backend, Socrata, Elasticsearch Connector, Google Analytics Reports, and more.
Slideshows and carousels
Make your website even more attractive by creating slideshows and carousels, which can include various kinds of content and be responsive. Add-on modules for the Views like Views Slideshow, Slick Carousel, Slick Views, and Views Bootstrap will help you with it.
Among the great filtering and sorting options of the Views there’s an option to set up content-based filtering based on dynamic information. For example, you can display all content created by certain users. Contextual filters are very convenient because the values are fetched programmatically or via a URL.
Adding a relationship to Views
To present related content on your Drupal 8 website, it’s necessary to create a relationship to a view. Then you will receive information that is not contained in the base table selected during the Views creation. In the advanced settings of the “Display” page, you will find the “Add relationship” button and a selection of tables to pull data from.
Sometimes it’s necessary to embed Views in your pages using PHP code. For this, there is a special views_embed_view() function.
This has just been a very small collection of the Views module’s special powers. It also has many more to supercharge your Drupal 8 website with. Our Drupal developers are ready to use them to the full for your website’s benefits!