This module allows you to set conditions based on specific Drupal route names. This is useful for controlling where and when certain elements, like blocks, become visible, similar to how the "Pages" condition works but by matching route names instead of URL paths.
Route Condition provides a Condition plugin that matches on route names instead of URL paths. Use it anywhere Drupal accepts condition plugins, such as block visibility or the Context module.
It works like the core "Pages" (RequestPath) condition, but you enter route names such as entity.node.canonical instead of paths such as /node/*. Route names don't change when path aliases, URL prefixes or languages change, so the condition keeps working.
Features
- Match one or more route names, one per line.
- Use
*as a wildcard:entity.*.canonicalmatches the canonical page of every entity type. - Use
<front>to match the front page. - Put
~before a route to exclude it. - Matching is case-insensitive.
- The block visibility form shows a summary of the configured routes in its vertical tab.
Requirements
Drupal 10.2 or later, 11 or 12. No other modules are needed.
Installation
composer require drupal/route_condition drush en route_condition
Edit a block. Under Visibility, open the Route tab and enter your routes.
Similar modules
- Core's Pages condition matches on URL paths, not route names.
Support
Report bugs and feature requests in the issue queue. Merge requests are welcome.
Ask your assistant about Route Condition
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.