Asset_metadata logical condition not evaluating correctly?


#1

Hi,

I have a customisation which has the following in the parse file -

MySource_AREA id_name=“og_show_description” design_area=“show_if”>
MySource_SET name=“condition” value=“logical” />
MySource_THEN>
meta property=“og:description” content="%asset_metadata_og.description%" />
/MySource_THEN>
MySource_ELSE>
meta property=“og:description” content="%asset_metadata_DCTERMS.description%" />
/MySource_ELSE>
/MySource_AREA>

In the customisation design area I have changed og_show_description to be customised and I have edited it and changed the Condition Settings to

Logical Condition
Logical Grouping - Match all keywords
Keywords - og.description

In the metadata for a standard page asset I have the og.description set to use the default value in the schema which is empty.

Regardless of if the og.description field is empty or not the logical condition will ONLY evaluate the else part. Is there something I am missing here or that I have done wrong? Why is it that even if I put in a value in the og.description field of the metadata for that asset it will execute the else part of the logical condition instead of the then part? The condition should be true and it should execute the then part as there is a value in og.description.

Edit: Please ignore the missing left arrow on the tags. I am not sure how to print out raw code here,


(Tim Davison) #2

Not around a system to check, but I think you need to set the keywords field in the customisation to the full keyword, i.e. “asset_metadata_og.description”, not just “og.description”. I don’t think you need to put the percentage signs in, but everything else is needed.

Also, not sure and this might change per version, but it may need to have a true/false output. I.e. keyword may need to be asset_metadata_og.description^notempty.

Depending on your version, and whether you need to be able to customise this, it might even be better to do this using keyword conditionals, e.g. I use the following to display a meta tag only if it’s filled in:

%begin_globals_asset_metadata_DCTERMS.subject%
  <meta name="DCTERMS.subject" content="%globals_asset_metadata_DCTERMS.subject%" />
%end_globals%

(Note: I’m using ‘globals’ above because I’m nesting this content into a design area.)

There is also an else option in there. Matrix manual page is here:
https://matrix.squiz.net/manuals/keyword-replacements/chapters/conditional-keywords

Looks like since v5.4 you can even inject these straight into the parse file (though I would probably still use nested content areas, personally).


#3

Ahhh there we go, silly me forgot the asset_metdata part.

That works now, thanks. :slight_smile: