Change record status: 
Project: 
Introduced in branch: 
8.3.x
Introduced in version: 
8.3.0
Description: 

Views now automatically exposes contextual filters as context for block plugins. That allows to explicitly pass data into those views blocks, for example the current node or user.

This is especially useful when using contributed modules like Page Manager and/or Panels, which allow to define URL-based or statically defined contexts that can then be passed to views blocks.

Since views does not have an explicit data type system, this mostly relies on contextual filter validation. To have a context exposed for a contextual filter, enable validation and select an entity type like User, Content or Term. It is also possible to expose a numeric or string context.

Additional information for developers

Both Argument and ArgumentValidator plugins can override the getContextDefinition() method to control the context definition that is exposed by their plugin, the following example is from the NumericArgument plugin:


  public function getContextDefinition() {
    if ($context_definition = parent::getContextDefinition()) {
      return $context_definition;
    }

    // If the parent does not provide a context definition through the
    // validation plugin, fall back to the integer type.
    return new ContextDefinition('integer', $this->adminLabel(), FALSE);
  }
Impacts: 
Site builders, administrators, editors
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done