{% extends "_layouts/main.html" %} {% import 'macros.twig' as macros %} {# Card de projeto reutilizável (usado nos dois grids por-2-sec) #} {% macro project_card(project) %} {% import 'macros.twig' as macros %} {% set p_slides = project.gallery.all() ?? [] %} {% set p_logo = project.main_logo.one() ?? null %} {% set state_colors = { '0': 'cccccc', '1': '00d52e', '2': 'ffb820', '3': 'e90a0a' } %}
{% if p_slides|length %}
{% for img in p_slides %} {{ img.title ?: project.title }} {% endfor %}
{% endif %} {% if p_slides|length > 1 %}
{% endif %}
{% if p_logo %} {% endif %}

{{ macros.limpar_paragrafos(project.title) }}

{% if project.location %}

{{ macros.limpar_paragrafos(project.location) }}

{% endif %}
{% if project.text %} {# texto corrido (sem
/tags) para o line-clamp de 3 linhas funcionar bem #}

{{ project.text|replace('//', ' ')|striptags|trim }}

{% endif %} {% if project.state.value %} {% set state_color = state_colors[project.state.value] ?? '00d52e' %}

{{ project.state.label|t }}

{% endif %}
{{ 'btn.ver_projeto'|t }}
{% endmacro %} {% block main %} {# Projetos divididos por `situation`: 0 -> 1º grid (e home) ; 1 -> 2º grid #} {% set all_projects = craft.entries() .section('projects') .orderBy('postDate desc') .all() %} {% set projects_main = all_projects|filter(p => p.situation.value == '0') %} {% set projects_second = all_projects|filter(p => p.situation.value == '1') %} {# ========================= SEC 1 — INTRO projects_section_1: - section_title (RTE) ========================= #} {% set sec1 = entry.projects_section_1.one() ?? null %} {% if sec1 %}
{% if sec1.section_title %}

{{ macros.limpar_paragrafos(sec1.section_title) }}

{% endif %}
{% endif %} {# ========================= 1º GRID — projetos com situation = 0 ========================= #} {% if projects_main|length %}
{% for project in projects_main %} {{ _self.project_card(project) }} {% endfor %}
{% endif %} {# ========================= SEC 2 — BANNER projects_section_2.section_title Só aparece se houver projetos com situation = 1 (acompanha o 2º grid). ========================= #} {% set sec2 = entry.projects_section_2.one() ?? null %} {% if sec2 and sec2.section_title and projects_second|length %}

{{ macros.limpar_paragrafos(sec2.section_title) }}

{% endif %} {# ========================= 2º GRID — projetos com situation = 1 (só se existirem) ========================= #} {% if projects_second|length %}
{% for project in projects_second %} {{ _self.project_card(project) }} {% endfor %}
{% endif %} {# ========================= SEC 3 — CONTACTO projects_section_3: - section_title (RTE) - image (asset) - image_2 (asset) (Formulário Freeform 'contacto'.) ========================= #} {% set sec3 = entry.projects_section_3.one() ?? null %} {% if sec3 %} {% set sec3_img = sec3.image.one() ?? null %} {% set sec3_img_2 = sec3.image_2.one() ?? null %}
{% if sec3.section_title %}

{{ macros.limpar_paragrafos(sec3.section_title) }}

{% endif %}
{{ freeform.form('contacto').render }}
{% if sec3_img %} {{ sec3_img.title }} {% endif %} {% if sec3_img_2 %} {{ sec3_img_2.title }} {% endif %}
{% endif %} {% endblock %}