2

I'm trying to create an Expression Engine loop (channel entries) that outputs an unordered list with each list item being an individual entry. Easy enough. But I'd also like each list item it outputs to have a unique class. For example, li class="column_one", li class="column_two", etc.

Can the channel entries tag do this? or do I have to add the classes with javascript?

9

Surely you just output somehting like:

<li class="unique_{entry_id}">What ever you are outputting here?</li>

Or perhaps use {count} or similar?

| improve this answer | |
4

Really common to use {count} for this, as suggested:

<li class="column_{count}">I'm item {count}</li>. 

I often combine {count} with {switch} and a truly unique identifier like {entry_id} like this:

<li class="list_{count} {switch='col1|col2'}" id="thing_{entry_id}">
  I'm Thing {entry_id) at List position {count} in Column {switch='col1|col2'}
</li>
| improve this answer | |

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.