1

I'm looping matrix entries and I'm trying to give each image a unique id. I've tried using {count}, but it's just outputting same number for each entry? What's the best way to do this with either EE logic or PHP?

Here's my current code. Essentially just trying to increment mainImg1, mainImg2, mainImg3, etc...

    <div div class="machine_parts_container">
        <h3>{image_title}</h3>
        <div class="machine_parts_left">
            <div class="machine_parts_left_img">
                <a class="fancybox-effects-c" href="{image}" title="{image_title}"><img id="mainImg" src="{image}" alt="{image_title} Diagram" /></a>
                <p>Click To Zoom Image</p>
                <input type="button" value="Print Image"  onclick="printImg()" />
            </div>
        </div>

        <div class="machine_parts_right">
            <div class="machine_parts_right_int">
                <div class="parts_table">
                    {table}
                </div>
            </div>
        </div>
    </div>
    {/machine_support_landing_parts}
2

{count} probably belongs to the outer {exp:channel:entries} loop. You want either {row_id}, {row_count}, or {row_index}, which Matrix provides.

https://docs.pixelandtonic.com/matrix/templating/field.html

1
  • 1
    Yep, {row_index} certainly works fine. Thank you. – frshjb373 Nov 6 '14 at 19:40

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.