<p>I figured it out by modifying the code from <a href="https://craftcms.stackexchange.com/questions/8630/transform-different-image-if-specific-id-or-order">this answer</a> on image transforms. Here's the basics of my markup.</p>

<pre><code>&lt;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"&gt;
&lt;/div&gt;
</code></pre>

CC BY-SA 3.0
2017-02-04T21:00:55.413Z
2017-02-04T21:00:55.413Z
2017-04-13T12:51:00.303Z
Jesse Winton
<p>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 <code>grid-one-half</code> and if there are three <code>grid-one-third</code> etc. to give my client more flexibility in making grids.</p>

<p>Thanks!</p>

<templating><plugin-neo>
Adding class based on length
# Adding class based on length

(Asked by: username_0 on 2017-02-04)

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!

**Tags:** templating, plugin-neo


---

## 1 answers

### Answer by username_0 on 2017-02-04. Score: 1

I figured it out by modifying the code from [this answer](https://craftcms.stackexchange.com/questions/8630/transform-different-image-if-specific-id-or-order) on image transforms. Here's the basics of my markup.


---

