Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Context Stack

Security covered Maintenance fixes only 234 sites

Part of the Context ecosystem · 11 projects

This module allows you to use data from stacked contexts, such as the currently viewed node and its related entities, in various parts of your Drupal site. It provides access to current, parent, and root contexts through tokens, enabling more dynamic content display and logic. Note that this module is no longer actively maintained and only receives security and maintenance fixes.

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 }
Drupal 9–10 · not 11 PHP >=7.4

Ask your assistant about Context Stack

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Jan 2023
Latest release
3 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core PHP Release date
1.1.2 Stable 9–10 PHP >=7.4 Feb 17, 2023
1.1.1 Stable 9–10 PHP >=7.4 Jan 27, 2023