ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Keeping track of a field group row count / index

March 29, 2011 11:45am

Subscribe [2]
  • #1 / Mar 29, 2011 11:45am

    Sean Delaney

    64 posts

    I have a custom field called prodimages in my weblog.

    I’ve set the field type to File.  I’ve published a page to my weblog and added 4 images.

    I can loop over my images using:

    {prodimages}
    {file_name}
    {/prodimages}

    But how can i keep track of the row index / counter?

    Basically I want to do something like this:

    {prodimages}
    {if row_count == 1}
    {file_name}
    {/if}
    {/prodimages}


    Sean

  • #2 / Mar 29, 2011 6:42pm

    Sue Crocker

    26054 posts

    Hi, Sean. You’re using EE’s built in File field type, right? It only allows you to use one image per field. So you’d have a different field name… ??

  • #3 / Mar 30, 2011 5:13am

    Sean Delaney

    64 posts

    Hi Sue,

    Yes, this is correct.  I have managed to close this issue out as I figured out I could use {count} within my {prodimages} tag call.

    So for example I was able to do this:

    {prodimages}
    {if count == 1}
    //set image as primary
    {if:else}
    //set image as thumbnail
    {/if}
    {/prodimages}

    Thanks your help!

    Sean

  • #4 / Mar 30, 2011 12:01pm

    Sue Crocker

    26054 posts

    Sounds good, Feel free to start a new thread if you have any more questions.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases