Conditional OR keyword modifier

(Erwin Strobel) #1

Just wondering if there is a keyword modifier to use as conditional OR

e.g. something like %begin_asset_metadata_fieldname_key^eq:valueA||valueB||valueC%


(John gill) #2


To get the effect of “equal to A, B or C” I’d proabbly use ^preg_match ( and put the conditions in the regular expression, but there’s no general purpose operators like that.

If a regexp doesn’t scratch your itch, you’re probably best served by reaching for SSJS (assuming you’re on 5.4+).

(Chiranjivi Upreti) #3

As an alternative to preg_match, you could use some trickery using in_array modifier with some dummy keyword. Something like below:


Here globals_dummy will return nothing however it will kick start the Matrix keyword replacement process chain. So globals_dummy^append:valueA,valueB,valueC^explode:, will return an array [valueA, valueB, valueC], which is fed to in_array modifier to check the nested keyword {asset_metadata_fieldname_key}.

Alternatively you could also use nested keyword in the eq modifier’s 3rd argument, however it will only work for check up to two values as you cannot nest a keyword within a nested keyword:

   // kw is either "v1" or "v2"

(Erwin Strobel) #4

Thank you all for your replies :slight_smile: