Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Token Conditions

Security covered Under active development 8 sites

Part of the Token ecosystem · 22 projects

Token Conditions provides a Token Matcher condition. It replaces tokens in a value, then compares the result with a value you expect. You can show a block only on nodes whose title starts with "Event:", only to a particular user, or only when a field is empty, all without writing code.

Token Matcher works like any other Drupal condition, so you can use it wherever conditions are used:

  • Block visibility
  • The Context module
  • Canvas pages, through Canvas Conditional Container visibility rules
  • Any other module that uses condition plugins

Features

  • Exact match: compare a token value with an expected value, which can also contain tokens.
  • Regex match: match a token value against a regular expression, such as /^News:/i. Invalid patterns are caught when you save.
  • Empty check: test whether a token value is empty.
  • Negation: reverse the result of any of these checks.
  • Contexts: the condition can use node, user and taxonomy term contexts. New conditions use the node and term from the current page by default.
  • Correct caching: per-user tokens make the result vary by user, and entity tokens add that entity's cache tags, so cached pages show the right result.

Examples

  • Show a promo block on event pages: source [node:title], regex /^Event:/.
  • Show a fallback block when a field is empty: source [node:field_subtitle], with "Check if value is empty" enabled.
  • Show content to one account only: source [current-user:name], expected value alice.

Post-installation

  • Blocks: when you place or edit a block, open the Token Matcher tab under Visibility.
  • Context: add a Token Matcher condition to a context.
  • Canvas: create a context that uses a Token Matcher condition, then select that context in a Conditional Container's visibility rules.

Requirements

  • Drupal 10.3 or later, or Drupal 11, for the 2.0.x branch.

Recommended modules

  • Token adds a token browser to the condition form, plus more tokens such as entity field tokens and [current-date:*].

Upgrading from 8.x-1.x

2.0.x is a rewrite for modern Drupal, including Drupal CMS. The plugin ID and configuration are unchanged, so existing conditions keep working without an update. Comparisons are stricter, though. Review the release notes for these behavior changes:

  • Exact matching is strict, so 01 no longer matches 1.
  • Token values inserted into regex patterns are escaped, so they match literally.
  • Values are compared as plain text, so write & rather than &.

Getting entities from the route without a mapped context still works, but it is deprecated and will be removed in 3.0.x.

Ask your assistant about Token Conditions

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
Nov 2026
Latest release
1 day ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

Version Type Core PHP Release date
2.0.0-beta1 Pre-release 8–9 Nov 20, 2026
2.0.x-dev Dev 10–11 Nov 20, 2026