1

I'm using Neo to allow my client to be able to create a content grid with child blocks. Now I'm wondering, is there a way that I can change the class of the output based on the number of items? For example, if there are two items I'd like to have the class grid-one-half and if there are three grid-one-third etc. to give my client more flexibility in making grids.

Thanks!

1 Answer 1

1

I figured it out by modifying the code from this answer on image transforms. Here's the basics of my markup.

<div class="{% if loop.length == 2 %}grid-one-half{% elseif loop.length == 3 %}grid-one-third{% elseif loop.length == 4 %}grid-one-quarter{% endif %} grid-item">
</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.