Conditional filters ?

Created on 28 February 2010, over 14 years ago
Updated 29 December 2023, 11 months ago

I want to be able to create a filter, and only make this filter enabled if a condition is met. In my case, the condition is related to the value of $cookie_domain. I was wondering if it is (or could be made to be) possible to put some php code into a filter which only causes it to process the filter when the condition in the php code is met.

Feature request
Status

Closed: works as designed

Component

Miscellaneous

Created by

🇬🇧United Kingdom TimAlsop

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Now you can use (php):

    if( \Drupal::routeMatch()->getRouteName() == 'entity.node.canonical' ){ /*CONDITON if node page*/
    	return $result = 
    		str_replace($matches[1], $matches[1] . 'PlusText', $matches[0]); /*you custom code here*/
    } else return $result = $matches[0]; /*no changes*/
    
Production build 0.71.5 2024