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.

2
  • Not really - can you please post more detail? Oct 24, 2014 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. Oct 24, 2014 at 13:31

2 Answers 2

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 %}
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' %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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