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.

Incremental class or IDs

August 22, 2011 11:20am

Subscribe [2]
  • #1 / Aug 22, 2011 11:20am

    MadhouseHQ

    10 posts

    Hello,
    I have an list of items for which I need a unique class name on each <li>.

    Currently I have something like:

    <ul>
    {exp:channel:entries}
    <li><a href="http://" class="itemN">This is a {custom_field}</a></li>
    {/exp:channel:entries}
    </ul>

    This gives me my list but with ALL classes as ‘itemN’ where ‘N’ needs to be an incremental number (item1, item2, item3 etc…).

    Can this be done?

    Thanks

  • #2 / Aug 22, 2011 11:24am

    Fusion Design

    128 posts

    Hi there,

    You should be able to use the count tag to do this

    <ul>
    {exp:channel:entries}
    <li><a href="http://" class="item{count}">This is a {custom_field}</a></li>
    {/exp:channel:entries}
    </ul>

    Hope this helps.

  • #3 / Aug 22, 2011 11:36am

    MadhouseHQ

    10 posts

    Ahhh… This works great except with Matrix.  I probably should have mentioned I was using Matrix :(

  • #4 / Aug 22, 2011 11:42am

    Fusion Design

    128 posts

    Matrix uses the {row_count} tag instead, does that help?

  • #5 / Aug 22, 2011 11:43am

    MadhouseHQ

    10 posts

    Yes, yes it does!  Thanks again!

  • #6 / Aug 22, 2011 11:44am

    Fusion Design

    128 posts

    Glad you could get it sorted!

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

ExpressionEngine News!

#eecms, #events, #releases