{% if item.children|length > 1 %}
{# Перегоняем в индексированный массив #}
{% set children = [] %}
{% for breadcrumb_item in item.children %}
{% set children = children|merge([breadcrumb_item]) %}
{% endfor %}
{% set route = app.request.get('_route') %}
{% set city = app.request.get('city') ?? null %}
{% set locale = app.request.locale ?? 'ru' %}
{% if route == 'profile_preview.page' %}
{#
На странице анкеты Москвы выводим крошки вида
Главная / ЗАО (то есть ссылка на округ) / Дорогомилово (то есть ссылка на район) / Кутузовская (то есть ссылка на метро) / индивидуалка Аня (Аня простым текстом, без ссылки)
(согласно https://redminez.net/issues/27876),
а на остальных Главная / Город / индивидуалка Имя
#}
{% set profile = options.profile ?? null %}
{% set main = [{label: 'Главная', uri: path('homepage')}, {label: city.name, uri: path('profile_list.list_by_city', {city: city.uriIdentity})}] %}
{% set children = main|merge([children[1]]) %}
<ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
<li class="" property="itemListElement" typeof="ListItem">
<a href="{{ (children|first).uri }}" property="item" typeof="WebPage"><span property="name">{{ (children|first).label }}</span></a>
<meta property="position" content="0">
</li>
{% set position = 1 %}
{% if city and city.id == 1 %}
{% set station = profile.stations|length ? profile.stations[0] : null %}
{% if profile and station and station.district and station.county %}
{#
<li class="" property="itemListElement" typeof="ListItem">
<a href="{{ path('profile_list.list_by_county', {city: city.uriIdentity, county: station.county.uriIdentity }) }}" property="item" typeof="WebPage"><span property="name">{{ station.county.name|trans }}</span></a>
<meta property="position" content="1">
</li>
<li class="" property="itemListElement" typeof="ListItem">
<a href="{{ path('profile_list.list_by_district', {city: city.uriIdentity, district: station.district.uriIdentity}) }}" property="item" typeof="WebPage"><span property="name">{{ station.district.name|trans }}</span></a>
<meta property="position" content="2">
</li>
#}
<li class="" property="itemListElement" typeof="ListItem">
<a href="{{ path('station_list.page', {city: city.uriIdentity}) }}" property="item" typeof="WebPage"><span property="name">Метро</span></a>
<meta property="position" content="2">
</li>
<li class="" property="itemListElement" typeof="ListItem">
<a href="{{ path('profile_list.list_by_station', {city: city.uriIdentity, station: station.uriIdentity}) }}" property="item" typeof="WebPage"><span property="name">{{ station.name|trans }}</span></a>
<meta property="position" content="3">
</li>
{% set position = 4 %}
{% else %}
{#
если у анкеты нет станции, то:
Южный (ЮАО), Донской, Ленинский проспект
#}
{#
<li class="" property="itemListElement" typeof="ListItem">
<a href="{{ path('profile_list.list_by_county', {city: city.uriIdentity, county: 'yuzhnyj-yuao' }) }}" property="item" typeof="WebPage"><span property="name">{{ locale == 'ru' ? 'Южный (ЮАО)' : 'South (SAD)' }}</span></a>
<meta property="position" content="1">
</li>
<li class="" property="itemListElement" typeof="ListItem">
<a href="{{ path('profile_list.list_by_district', {city: city.uriIdentity, district: 'donskoj'}) }}" property="item" typeof="WebPage"><span property="name">{{ locale == 'ru' ? 'Донской' : 'Donskoy' }}</span></a>
<meta property="position" content="2">
</li>
#}
<li class="" property="itemListElement" typeof="ListItem">
<a href="{{ path('station_list.page', {city: city.uriIdentity}) }}" property="item" typeof="WebPage"><span property="name">Метро</span></a>
<meta property="position" content="2">
</li>
<li class="" property="itemListElement" typeof="ListItem">
<a href="{{ path('profile_list.list_by_station', {city: city.uriIdentity, station: 'leninskij-prospekt'}) }}" property="item" typeof="WebPage"><span property="name">{{ locale == 'ru' ? 'Ленинский проспект' : 'Leninskij prospekt' }}</span></a>
<meta property="position" content="3">
</li>
{% set position = 4 %}
{% endif %}
{% else %}
<li class="" property="itemListElement" typeof="ListItem">
<a href="{{ path('profile_list.list_by_city', {city: city.uriIdentity}) }}" property="item" typeof="WebPage"><span property="name">{{ city.name }}</span></a>
<meta property="position" content="1">
</li>
{% set position = 2 %}
{% endif %}
<li property="itemListElement" typeof="ListItem">
<span property="name">{{ profile.name|trans }}, {{ profile.personParameters.age }}</span>
<meta property="position" content="{{ position }}">
</li>
</ul>
{% else %}
<ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
{% if route == 'profile_list.list_by_district' %}
{# Убираем название округа #}
{% set children = children | map((k) => k) | filter((v, k) => k != 2) %}
{% elseif route == 'profile_list.list_by_county' %}
{# Убираем слово районы #}
{% set children = [children[0], children[2]] %}
{% elseif route == 'profile_list.list_by_station' %}
{# Убираем слово районы #}
{% set children = [
children[0],
{ label: 'Метро', uri: path('station_list.page', {city: city.uriIdentity}) },
{ label: children[1].label, uri: children[1].uri }
] %}
{% endif %}
{% if city.id == 1 %}
{# Делаем првый элемент "Главная" #}
{% set main = [{label: 'Главная', uri: path('homepage')}] %}
{% set children = main|merge(children|slice(1, children|length - 1)) %}
{% else %}
{# Делаем првый элемент "Главная", второй - город #}
{% set main = [{label: 'Главная', uri: path('homepage')}, {label: city.name, uri: path('profile_list.list_by_city', {city: city.uriIdentity})}] %}
{% set children = main|merge(children|slice(1, children|length - 1)) %}
{% endif %}
{% for breadcrumb_item in children %}
<li class="{% if loop.last %}last-crumb{% endif %}" property="itemListElement" typeof="ListItem">
{% if not loop.last %}
<a href="{{ breadcrumb_item.uri }}" property="item" typeof="WebPage"><span property="name">{{ breadcrumb_item.label|trans({}, 'breadcrumbs') }}</span></a>
{% else %}
<span property="name">{{ breadcrumb_item.label|trans({}, 'breadcrumbs') }}</span>
{% endif %}
<meta property="position" content="{{ loop.index }}">
</li>
{% endfor %}
</ul>
{% endif %}
{% endif %}