I have 2 Matrix fields in an entry type, both of which use Dropdown fields:
Matrix: urls
address (block type)
context (dropdown field values include 'own')
address
urn
Matrix: logos
svg (block type)
usage (dropdown field values include 'monoNeg')
aspectRatio
svg (source code)
img (block type)
usage (equivalent dropdown field)
img
Entries are assigned to a footer
Globals field, from which I'm pairing a urls value with a logos value in a loop to write linked logos.
I can get the relevant URL easily enough with:
{% for org in footer.footerAccreditations %}
{% set orgUrl = org.urls.context('own').one() %}
{{ orgUrl.address }}
{% endfor %}
Which prints the address
URL just fine.
But the same approach for the svg
logo isn't working. Either one of the following returns 0
, even when I know for sure that the org
entry in question has a monoNeg
SVG source.
{% set negLogoDirect = org.logos.usage('monoNeg').one() %}
{{ negLogoDirect|length }}
{% set negLogoTyped = org.logos.type('svg').usage('monoNeg').one() %}
{{ negLogoTyped|length }}
If I run through an all
loop for the logos their usage
reports exactly as I would expect:
{% set orgLogos = org.logos.all() %}
{% for logo in orgLogos %}
{{ logo.usage }}
{% endfor %}
I assume I can make my template more verbose and get what I need, but I don't see why the same approach should work for one Matrix dropdown field and not for another.
Where am I going wrong?