1

asset.getNext().fieldName does not work but might help explain what I was aiming for.

To be more specific, for where there are multiple images in an entry, I want to assign a class to each depending on its next image’s field value. Also, the field I’m trying to get a value from is a radio field.

  • Not really - can you please post more detail? – Brandon Kelly Oct 24 '14 at 13:06
  • Can you post your full template code? Sounds like asset.getNext().fieldName should work, but hard to tell without seeing more code. – Brandon Kelly Oct 24 '14 at 13:31
2

I found this to work for what I needed:

{% set nextImage = image.getNext() %}
{% if nextImage %}

    {% if nextImage.checkboxFieldHandle.contains('value') %}
        {# Do something #}
    {% endif %}

{% endif %}
| improve this answer | |
1

I never used that getNext() method with craft.asset, but maybe it works if you explicitly feed it with parameters?

Another idea is to use loop variables:

{% set myClass = not loop.last and entry.myAssets[loop.index].fieldName == '1' ? ' YEY' %}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.