Use Drupal Conditions Plugin API to include / exclude by certain conditions

Created on 4 December 2024, 14 days ago

Problem/Motivation

Klaro currently uses regular expressions to define paths where the consent manager should appear or not.
I think the reason might be, that the condition is checked cliend-side in JS.

Using regular expressions for paths in Drupal is very untypical and hard for non-developers. Instead you'd expect paths syntax like /path/* known from blocks and other core / contrib modules.

While I think the functionality needs to be kept, I think it would make sense to exclude certain pages from Klaro entirely, for example /admin/*

One way to do this would be to just add a textarea with one exclusion per line.

But by far more flexible would be to use Drupals Condition Plugin API (which sadly is not very well documented).
https://www.previousnext.com.au/blog/using-drupal-8-condition-plugins-api (or for example look into https://git.drupalcode.org/project/posthog/-/blob/1.x/modules/posthog_js...

Conditions then couldn't only by paths, but also Theme, Language, Roles, ... etc. that can also be added by contrib modules.
But danger, mind this core bug: 🐛 Drupal Current theme condition plugin should provide an option to select all themes Needs review

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024