I’m wanting to return the selected key and value in an array.
For example [1:entre,2:main,3:pudding], where 1,2,3 are the key for the select field and entre, main and pudding.
I know that there is %asset_metadata_name_key% and %asset_metadata_name_value% which will return selected values in separate lists.
%asset_metadata_name% - only returns the part that is selected to show on frontend.
So am I right in that you’re asking about possibly a multiple-selection Select field, and you want the values you select returned together as, say, a JSON array?
At the moment I don’t believe there is a feature that provides what you want for that, no.
Yes I think you have got it - I want both key and value togoether.
The use case is that I need both parts.
I will find another solution.
It seems weird that we specify the key and value when setting up the metadata schema but can only get the information returned via keywords separately.
That keyword gives me all the available options not just the key/value pairs that have been selected.
I ended up using ssjs
<script runat="server">
var value = %asset_metadata_field_value^explode:;^empty:[]%;
var url = %asset_metadata_field_key^explode:;^empty:[]%;
var number = %asset_metadata_field^explode:;^count%;
print('<ul>');
for (var i = 0, len = number; i < len; i++) {
print('<li><a href=url[i].trim()+'">'+value[i]+'</a></li>');
}
print('</ul>');
</script>