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.*.canonical matches 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.

Supporting organizations: 
Maintenance
Maintenance
Sponsored initial development
Sponsored initial development

Project information

Releases