Keyword for Finding if a Schema Exists


(Nick Papadatos) #1

Matrix Version: 5.4

Can someone help me with a keyword (if it exists) to find if a Matrix asset (PDF) has a metadata schema applied to it.

Doing an audit on PDF’s using an Asset Listing

Cheers
N


(John gill) #2

I’m fairly confident there is no such keyword.

I believe that the Asset->Schema association isn’t even loaded when an asset is processed for the frontend. The metadata is picked up from an on-disk copy which only contains field info.

(Obviously the dirty solution would be to add a field with a default value to the schema, then regenerate the metadata for all assets with that schema, then check for the default value in your listing. Ew)


(Nick Papadatos) #3

I thought as much John thanks, yep ew! :slight_smile:

Cheers
Nick


(Bart Banda) #4

If you use the %asset_data_metadata% keyword it should give you the asset IDs of the metadata fields applied to the asset, from that you should be able to tell what Schema is applied.


(Emily) #5

And I expect you could then use the ^eq modifier (or similar) to display whether or not a specific Schema (by asset ID) is applied as a true/false response.


(John gill) #6

Using Bart’s neat trick (:+1:), youcouldn’t check for a schema but you could check for a field even if that field has no value set. So if you have a field called select with the assetid 18058, you’d use

%begin_asset_data_metadata^index:select^index:fieldid^eq:18058%

I just tested it with on:

  • Page has schema and field has value
  • Page has schema but field has no value
  • Page does not have schema

and it behaves as expected, true for the first two and false for the third.