Newer
Older
pre-www / src / blocks / cards-grid.twig
<div class="cards-container">
    <div class="cards-container__inner">
        {% for item in block.content.items %}
            {% if item.post_type == "pages" %}
                {% set card = post_type.pages[item.id] %}
            {% else %}
                {% set card = post_type[~item.post_type~].items[~item.id~] %}
            {% endif %}
            
            {% set card = card|merge(item.attr) %}
            <a href="#" class="card card-grid-item card-grid-item--{{card.category|lower}}{% if card.featured_image != null %} card-grid-item--has-background{% endif %}">
                {% if card.featured_image != null %}
                    <div class="card-grid-item__bg">{% include "../layout/partials/picture.twig" with {"image": card.featured_image } %}</div>
                {% endif %}
                
                <div class="card-grid-item__header">
                    {% if card.show_category %}
                        <p class="card__category">{{card.category}}</p>
                    {% endif %}
                </div>
                {% if card.category == "Eventi" %}
                    <p class="card__date">{{card.date.start|date('d')}} - {{card.date.end|date('d.m.Y')}}</p>
                {% endif %}
                <div class="card__title">
                    <p>{{card.title}}</p>
                </div>
            </a>
        {% endfor %}
    </div>
</div>