Important points of Drupal 8 view module

Important points of Drupal 8 view module

The View module is very important and commanly used for almost all type that why Drupal comunity added this module as core module in Drupal 8 , Here are the important points you should know about this module.

What is contextual filter in view module

You can configure a view so that it is filtered dynamically, depending on the context. For example, you could use a contextual filter to add a block that contains related content or that presents a list of articles by the same author.

The View module is very important and commanly used for almost all type that why Drupal comunity added this module as core module in Drupal 8 , Here are the important points you should know about this module.

What is contextual filter in view module

You can configure a view so that it is filtered dynamically, depending on the context. For example, you could use a contextual filter to add a block that contains related content or that presents a list of articles by the same author.

When the filter value is not available

This section provide lot of options when the filter is not availble so that view display content when the condition is false

  • Display all results for the specified field
  • Provide default value. content ID from url,Fixed,Query parameter, raw value from url,Taxonomy term ID from URL,User Id from logged in user,User Id from route context
  • Hide view
  • Display a summary
  • Display contents of "No results found"
  • Display "Access Denied"

When the filter value is available or a default is provided

This section provide lot of options when the filter is availble so that view display content when the condition is true

Naming Views Templates

Each type of the view templates above can be overridden with a variety of names. The template name is a concatenation of (base template name, view machine name, view display type and view display id - separated by 2 hyphens "--").

The following are the possible template names sorted by precedence:

  • [base template name]--[view machine name]--[view display id].html.twig
  • [base template name]--[view machine name]--[view display type].html.twig
  • [base template name]--[view display type].html.twig
  • [base template name]--[view machine name].html.twig
  • [base template name].html.twig

For example; If we want to override "views-view.html.twig" template for our view, the following template names are valid: [base template name]--[view machine name].html.twig

  • views-view--articles-accordion--page.html.twig
  • views-view--page.html.twig
  • views-view--articles-accordion.html.twig
  • views-view.html.twig
Tags