Improve context logic for filter processing.

Created on 28 August 2013, over 11 years ago
Updated 16 January 2025, about 1 month ago

From #2055307: Is there any valid reason why this filter can't cache? :

As for the context, the concept is that upon saving/updating any entity that is using this filter and has valid tokens in the available text fields, the tokens would be modified to add enough context so that when the tokens are processed an entity_load() function could be called.

Obviously to do this a non-standard token format would have to be used, but then during the process stage the token would be transformed back to it's original state before being passed through token_replace().

Something like: [current-date:year|entity_type:node|entity_id:1]

In Wysiwyg Fields, I also used a 'cache' timestamp so when re-editing Filter would re-process the tokens again even if they seemingly hadn't changed (to account for changes in the token values themselves).

 

Attached in comment #1 is a patch using this approach. It is definitely a complex issue, and while I haven't done the testing to back it up, I suspect that this approach will improve performance as it's don't the heavy processing only when the Entity is being saved.

The added benefit of this implementation is that you could manually define the context of your tokens when entering the tokens, so you could have a Node token referring to another Node, or have a User token in a Node body field that actually works.

What hasn't been done is the language handling, but it shouldn't be a huge issue to have that added.

Feature request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇦🇺Australia Deciphered

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.

Production build 0.71.5 2024