{%- set route = app.request.attributes.get('_route') -%}
{%- set city = app.request.attributes.get('city') ?? null -%}
{%- set locale = app.request.locale ?? 'ru' -%}
{%- set isMainCity = city == default_city() -%}
{%- if item.children|length > 1 -%}
{# Перегоняем в индексированный массив #}
{% set children = [] %}
{% for breadcrumb_item in item.children %}
{% set children = children|merge([breadcrumb_item]) %}
{% endfor %}
{% if route == 'profile_preview.page' %}
{% set profile = options.profile ?? null %}
{% set station = profile.stations|length ? profile.stations[0] : null %}
{#{% set main = city == default_city() ? [{label: city.name, uri: path('profile_list.list_by_city', {city: city.uriIdentity})}] : [{label: 'Главная', uri: path('homepage')}, {label: city.name, uri: path('profile_list.list_by_city', {city: city.uriIdentity})}] %}#}
{% set main = isMainCity ? [{label: 'Главная', uri: path('profile_list.list_by_city', {city: city.uriIdentity})}]
: [
{label: 'Главная', uri: path('homepage')},
{label: 'Проститутки ' ~ city.name|geo_name('genitive'), uri: path('profile_list.list_by_city',
{city: city.uriIdentity})}
] %}
{% if station and station.district and station.district.county %}
{% set main = main|merge([{label: station.district.county.name|trans, uri: path('profile_list.list_by_county', {city: city.uriIdentity, county: station.district.county.uriIdentity})}]) %}
{% endif %}
{% if station and station.district %}
{% set main = main|merge([{label: station.district.name|trans, uri: path('profile_list.list_by_district', {city: city.uriIdentity, district: station.district.uriIdentity})}]) %}
{% endif %}
{% if profile and station %}
{% set main = main|merge([{label: station.name|trans , uri: path('profile_list.list_by_station', {city: city.uriIdentity, station: station.uriIdentity})}]) %}
{% endif %}
{% set children = main|merge([children|last]) %}
<ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
{% 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 }}</span></a>
{% else %}
<span property="name">{{ breadcrumb_item.label }}, {{ profile.personParameters.age|plural('год') }} ID {{ profile.id }}</span>
{% endif %}
<meta property="position" content="{{ loop.index }}">
</li>
{% endfor %}
</ul>
{% else %}
<ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
{# Делаем првый элемент "Главная", второй - город #}
{#{% set main = city == default_city() ? [{label: city.name, uri: path('profile_list.list_by_city', {city: city.uriIdentity})}] : [{label: 'Главная', uri: path('homepage')}, {label: city.name, uri: path('profile_list.list_by_city', {city: city.uriIdentity})}] %}#}
{% set main = isMainCity ? [{label: 'Главная', uri: path('profile_list.list_by_city', {city: city.uriIdentity})}] : [{label: 'Главная', uri: path('homepage')}, {label: city.name, uri: path('profile_list.list_by_city', {city: city.uriIdentity})}] %}
{% if 'profile_list.list_by_station' in route %}
{% set main = main|merge([{label: 'Метро' , uri: path('station_list.page', {city: city.uriIdentity})}]) %}
{% endif %}
{% set children = main|merge([children|last]) %}
{% 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 }}</span></a>
{% else %}
<span property="name">{{ breadcrumb_item.label }}</span>
{% endif %}
<meta property="position" content="{{ loop.index }}">
</li>
{% endfor %}
</ul>
{% endif %}
{% else %}
{% if (route == 'profile_list.list_by_city' or route == 'profile_list.list_by_city._pagination')
and city != default_city() %}
{#{% set main = city == default_city() ? [{label: city.name, uri: path('profile_list.list_by_city', {city: city.uriIdentity})}] : [{label: 'Главная', uri: path('homepage')}, {label: city.name, uri: path('profile_list.list_by_city', {city: city.uriIdentity})}] %}#}
{% set main = isMainCity ? [{label: 'Главная', uri: path('profile_list.list_by_city', {city: city.uriIdentity})}] : [{label: 'Главная', uri: path('homepage')}, {label: city.name, uri: path('profile_list.list_by_city', {city: city.uriIdentity})}] %}
{% set children = main %}
<ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
<li property="itemListElement" typeof="ListItem">
<a href="{{ (children|first).uri }}" class="std-hover-link" property="item" typeof="WebPage"><span property="name">{{ (children|first).label }}</span></a>
<meta property="position" content="0">
</li>
<li property="itemListElement" typeof="ListItem">
<span property="name">{{ (children|last).label }}</span>
<meta property="position" content="1">
</li>
</ul>
{% endif %}
{% endif %}