I would like to display in a loop a div class one time in two (Symfony)

I’m working on a personal project and I want to do this:

enter image description here

So there is my code with a loop which works well:

  {% for uneInfo in lesInfos %}
        <div class="row featurette ">
            <div class="col-md-7 {% if (loop.first or loop.last) %} order-md-0 {% else %} order-md-2 {% endif %}">
                <h2 class="featurette-heading"> {{ uneInfo.title }} </h2>
                <p class="lead">{{ uneInfo.description }}</p>
            </div>
            <div class="col-md-5 {% if (loop.first or loop.last) %} order-md-0 {% else %} order-md-1 {% endif %} ">
                <img class="featurette-image img-fluid mx-auto" data-src="holder.js/500x500/auto"
                     alt="Generic placeholder image">
            </div>
        </div>

        <hr class="featurette-divider">
    {% endfor %}

On my page it look like this:

enter image description here

How can I alternate the display in my loop? I work with Symfony.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *