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 valuealice.
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
01no longer matches1. - 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.
Project information
- Project categories: Content display
14 sites report using this module
- Created by tedbow on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
Releases
Rewritten for modern Drupal
Development version: 2.0.x-dev updated 20 Nov 2026 at 19:46 UTC



