{#- Home page body of an education authority (site.is_authority): a portal rather than a school site.
Hero with figures, quick links, the catalogue of subordinate organisations (site.children), then
announcements and news, contacts. Used by pages/home.html of base and of child templates, so a
child keeps its own hero (blocks/hero.html) and still gets the portal. The catalogue is shown
only when the core sends site.children (an empty list gives a quiet empty state). -#}
{% set p_has_children = site.children is defined and site.children is not none %}
{% set p_kids = site.children if (p_has_children and site.children) else [] %}
{% set p_auths = p_kids|selectattr('kind', 'eq', 'authority')|list %}
{% set p_orgs = p_kids|rejectattr('kind', 'eq', 'authority')|list %}
{% set ns_p = namespace(kinds=[]) %}
{% set p_found = p_orgs|map(attribute='kind')|unique|list %}
{% for k in ['school', 'kindergarten', 'college'] %}{% if k in p_found %}{% set ns_p.kinds = ns_p.kinds + [[k, p_orgs|selectattr('kind', 'eq', k)|list|length]] %}{% endif %}{% endfor %}
{% for k in p_found %}{% if k not in ['school', 'kindergarten', 'college'] %}{% set ns_p.kinds = ns_p.kinds + [[k, p_orgs|selectattr('kind', 'eq', k)|list|length]] %}{% endif %}{% endfor %}
{% set p_kinds = ns_p.kinds %}
{% set p_auths_n = p_auths|length %}
{% set p_total = p_orgs|length + (p_auths|map(attribute='children_count', default=0)|sum) %}
{% set hero_eyebrow = t('portal.eyebrow') %}
{% set hero_stats = true %}
{% set hero_overlap = home and home.sections %}
{% include "blocks/hero.html" %}
{% if home and home.sections %}
{{ t('home.sections') }}
{% set tiles = home.sections %}{% include "blocks/section-tiles.html" %}
{% endif %}
{% if p_has_children %}{% include "blocks/catalogue.html" %}{% endif %}
{% set ann_first = settings.announcements_first if (settings is defined and settings.announcements_first is defined) else true %}
{% set ann_band = true %}{% set ann_tint = ann_first and home and home.feed %}
{% if ann_first %}{% include "blocks/announcements.html" %}{% endif %}
{% include "blocks/home-news.html" %}
{% if not ann_first %}{% include "blocks/announcements.html" %}{% endif %}
{% set c = site.contacts %}
{% if c and (c.address or c.phone or c.email) %}
{% endif %}