0

I'm converting some code over from using grid fields with images to use a single Assets field instead. All good so far.

But I need a way to get at the index (current asset number while looping through the field tag pair).

Looking over the docs, I don't see an obvious way to do this. {my_asset_field:index} doesn't appear to be a valid expression.

0

When you say 'index' do you mean something like the {count} variable in a Channel Entries loop?

If so then I believe (if my memory serves me correctly) that the files tag pair allows you to use the {count} variable inside it.

I really hope I'm not remembering this incorrectly though.

2
  • Yep, you're correct -- see my answer above. Thanks for your help. Sep 11 '14 at 17:31
  • Ah excellent. Glad you have it all working now.
    – Mark Bowen
    Sep 11 '14 at 18:05
0

You're correct, even though it's not documented anywhere on the Assets documentation, I discovered that {count} does indeed work for it.

If you're like me, and needed an index (zero-based), I found that this plugin will do the trick for you without having to enable PHP for your template page:

http://devot-ee.com/add-ons/mh-index

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.