AND logic in Conditional Keywords?


(gja) #1

**Matrix Version:**5.4.1.2

I’m wondering if it is possible to have an AND condition within conditional keywords?

For example:
%begin_globals_asset_metadata_myfield^striphtml% AND %begin_globals_asset_metadata_myfield1^striphtml%
Do something if both conditions are true
%else_globals%
something else if not
%end_globals%

Checking the manuals, it seems that I have to do additional begin - else - end conditions which means that the else case needs to be duplicated.

Any ideas?

Thanks Georgina.


(Bart Banda) #2

There are a couple of ways you can do that, one of them simply using SSJS, which would be the “cleanest” way, otherwise, you can either try:

%begin_globals_asset_metadata_myfield^striphtml%
  %begin_globals_asset_metadata_myfield1^striphtml%
    Do something if both conditions are true
  %end_globals%
%end_globals%

or

%begin_globals_asset_metadata_myfield^striphtml^notempty:{globals_asset_metadata_myfield1^striphtml}%
Do something if both conditions are true
%end_globals%


(gja) #3

Thanks Bart,

I went with
%begin_globals_asset_metadata_myfield^striphtml^notempty:{globals_asset_metadata_myfield1^striphtml}%
Do something if both conditions are true
%end_globals%

I also needed the else condition, so the nested begin statements were just too messy.

From reading the manuals, I’ve worked out how %begin_globals_asset_metadata_myfield^striphtml^notempty:{globals_asset_metadata_myfield1^striphtml}% works, but it does mess with my mind.

Georgina.