I have an asset listing that's grouped by the values available in a metadata selection field. My asset listing displays these options as headings for the group listings. I'd like to display a small icon alongside each of those headings (a different one for each field). Is this possible?
Displaying a thumbnail with a metadata field in an asset listing
Hey Barb, can you post what the format is of your group type format?
Where would the icon data come from? Each grouping value? Or would it be the same icon for all groups?
Hi Bart,
Not sure what you mean by 'format of your group type format'.
For group format I've just got this at the moment: %group_name%
%group_listing%
What I'd like is to be able to display a small thumbnail alongside each group name. These don't exist yet as I wanted to find out if there's a way to associate a different one with each of the group names (which as I said, are metadata options).
Assuming the group names are based on a single metadata field value, and assuming these values a pre-defined (e.g. a select metadata field) you would do something like this:
<h2> %asset_metadata_yourField^eq:value1:<img src="./?a=xxx" />% <!-- icon for value 1 --> %asset_metadata_yourField^eq:value2:<img src="./?a=xxx" />% <!-- icon for value 2 --> %asset_metadata_yourField^eq:value3:<img src="./?a=xxx" />% <!-- icon for value 3 --> %asset_metadata_yourField% <!-- the actual value --> </h2> %group_listing%
In the above, each of the keyword replacements using ^eq happens separately. If the value is not equal then nothing prints out, so only one of the them should print. Downside to this approach is, of course, that you have a finite enumeration. I.e. it will not handle dynamic inputs. E.g. a select metadata field, is ok. You know exactly what values are possible. A multiple text field, not possible, as the exact values could be anything.
(Also, instead of using actual image tags you could use classnames instead and use :before/:after psueudos with icon glyphs, for example).
Unless I've misunderstood what you're trying to do.
Thanks Tim - you haven't misunderstood at all. This is exactly what I was after.
Unfortunately this isn't giving me a result. Neither the field values nor the icons are displaying.
Here's my code:
Ah, right you are. Sorry, my bad.
Ok, so I'm assuming to get the group you are grouping by %asset_metadata_EzyReg% (on the grouping screen). Then in the group format change it to:
<h2> %group_name^eq:Boating:<img src="./?a=xxx" />% %group_name^eq:Licenses:<img src="./?a=xxx" />% ... etc ... %group_name% </h2> %group_listing%
(i.e. use keyword group_name instead of asset_metadata.)
Same principle applies, when you group by a metadata field the group name takes on the value of the metadata field. Again, sorry for leading you astray.
What version of Matrix are you using? I know not all keyword modifiers work in all contexts for all versions of Matrix. I've done a quick test and the above approach is working fine for me.
Did you look at the source code returned? Change the image code to simple yes/no and see if that render. That will tell you whether the keyword is not working or some other syntax error.