Important: Due to resource problems, this module is not recommended anymore. Only security and maintenance fixes will be applied.
Use data from stacked context in Blocks, Views, Tokens and anywhere context is used.
Installation
- This module requires no modules outside of Drupal core.
- Install the module as you would normally install a contributed Drupal module. Visit https://www.drupal.org/node/1897420 for further information.
Usage
Once installed, you get a variety of options to choose from in the configuration of Blocks via Block Layout, Layout Builder and default arguments for Views contextual filters, namely from the following available context stacks:
- The "view" context is a stack of entities being viewed. For example, if you view a node in full view mode which in turn renders a user in picture view mode, you can access both entities. You need to install the "Context Stack View" sub-module for being able to use the "view" context stack.
- The "form" context is a stack of entities that belong to a form that is being displayed. For example, when you have a form to edit a node opened on your page, and that form contains another entity via inline entity form, you can access both entities. You need to install the "Context Stack Form" sub-module for being able to use the "form" context stack.
- The "account" context is a stack of current users. This stack may be of interest if you want to do some nested account switching. You need to install the "Context Stack Account" sub-module for being able to use the "account" context stack.
For each stack, you can access the current context, but also the parent (superordinate) context and root context.
You can access "current", "parent" and "root" contexts via Tokens, for example [current:view:node:title], [parent:view:node:title], [root:view:node:title].
Complementary modules
This module may be especially useful when using the Token filter module, allowing to access the current node or other entities from the "view" stack.
The Views Tokenized module enables using Tokens within Views, including all Tokens provided by Context Stack.
The ECA Context module integrates ECA: Event - Condition - Action by providing its own "eca" context stack. That enables you to access objects defined from parent and root processes.
The Flow module contains a "flow" context stack integration.
API
This module is a framework for other modules that need complex context logic. Besides "view" and "account", additional stack purposes can be added by service definition like the following in your services.yml file:
services:
context_stack.my_stack:
class: Drupal\context_stack\ContextStack
factory: ['@context_stack.factory', createStack]
arguments: [my_stack]
tags:
- { name: context_stack }
Project information
Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed.Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: Content editing experience, Developer tools
- Ecosystem: Token
277 sites report using this module
- Created by mxh on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
