asset_metadata_X^as_asset keyword combination


(Lewis) #1

6.41

I’m trying to use an asset metadata related asset field with the ^as_asset keyword modifier, in the Default Format bodycopy of an asset listing, but I’m not getting the results I’d expect.

Instead of the ^as_asset keyword iterating through the asset ID(s), and printing out (for example, the asset names), nothing happens.

I’m using an related asset metadata field elsewhere in our site, to supply asset IDs to the dynamic parameters section of another asset listing, and that works fine.

It seems the related asset metadata field doesn’t supply a suitable array for the ^as_asset keyword to use in this context?


(Mel Freeman) #2

Hi Lewis,

If your related asset field is returning an array, you will need to use an asset listing, as you’ve already said, but because you’re already in an asset listing, it’s going to be nested,

The way I’ve found that works is that within your asset listing, use a nested content asset listing, and pass the array in as an additional GET parameter using %list_current_asset_metadata_X%

On the nested content asset listing, pass “Array of specific asset IDs or selection group (specified assets must be children of the static related node)” into the asset listing as a dynamic parameter (GET).

Mel


(Lewis) #3

Hi @MelFreeman. Thanks for your reply!

I thought about that - In my case, this would mean nesting one asset listing inside another, which seem like overkill for what I’m trying to do. The manual doesn’t discourage the use of the ^as_asset keyword ‘inline’ - i.e. in amongst other keywords in a content container, so it’s shame it doesn’t work.

If it’s the only way it’ll work (which certainly seems like it), I’ll have to do that instead maybe.

Thanks for your reply!


(Lewis) #4

@MelFreeman - had a response from Support. They suggested using the keyword modifier ^json_decode in this scenario, which worked.

So you get something like %asset_metadata_someRelatedAssetField^json_decode^index:0^as_asset:asset_name% for example


(Mel Freeman) #5

I’ve seen and used this example before, but wasn’t aware you could get it aware to loop through an array.