templates/_menu/breadcrumbs.html.twig line 1

Open in your IDE?
  1. {%- set route = app.request.attributes.get('_route') -%}
  2. {%- set city = app.request.attributes.get('city') ?? null -%}
  3. {%- set locale = app.request.locale ?? 'ru' -%}
  4. {%- set isMainCity = city == default_city() -%}
  5. {%- if item.children|length > 1 -%}
  6.     {# Перегоняем в индексированный массив #}
  7.     {% set children = [] %}
  8.     {% for breadcrumb_item in item.children %}
  9.         {% set children = children|merge([breadcrumb_item]) %}
  10.     {% endfor %}
  11.     {% if route == 'profile_preview.page' %}
  12.         {% set profile = options.profile ?? null %}
  13.         {% set station = profile.stations|length ? profile.stations[0] : null %}
  14.         {#{% 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})}] %}#}
  15.         {% set main = isMainCity ? [{label: 'Главная', uri: path('profile_list.list_by_city', {city: city.uriIdentity})}]
  16.                                  : [
  17.                                         {label: 'Главная', uri: path('homepage')},
  18.                                         {label: 'Проститутки ' ~ city.name|geo_name('genitive'), uri: path('profile_list.list_by_city',
  19.                                         {city: city.uriIdentity})}
  20.                                     ] %}
  21.         {% if station and station.district and station.district.county %}
  22.             {% 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})}]) %}
  23.         {% endif %}
  24.         {% if station and station.district %}
  25.             {% set main = main|merge([{label: station.district.name|trans, uri: path('profile_list.list_by_district', {city: city.uriIdentity, district: station.district.uriIdentity})}]) %}
  26.         {% endif %}
  27.         {% if profile and station %}
  28.             {% set main = main|merge([{label: station.name|trans , uri: path('profile_list.list_by_station', {city: city.uriIdentity, station: station.uriIdentity})}]) %}
  29.         {% endif %}
  30.         {% set children = main|merge([children|last]) %}
  31.         <ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
  32.             {% for breadcrumb_item in children %}
  33.                 <li class="{% if loop.last %}last-crumb{% endif %}" property="itemListElement" typeof="ListItem">
  34.                     {% if not loop.last %}
  35.                         <a href="{{ breadcrumb_item.uri }}" property="item" typeof="WebPage"><span property="name">{{ breadcrumb_item.label }}</span></a>
  36.                     {% else %}
  37.                         <span property="name">{{ breadcrumb_item.label }}, {{ profile.personParameters.age|plural('год') }} ID {{ profile.id }}</span>
  38.                     {% endif %}
  39.                     <meta property="position" content="{{ loop.index }}">
  40.                 </li>
  41.             {% endfor %}
  42.         </ul>
  43.     {% else %}
  44.         <ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
  45.             {# Делаем првый элемент "Главная", второй - город #}
  46.             {#{% 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})}] %}#}
  47.             {% 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})}] %}
  48.             {% if 'profile_list.list_by_station' in route %}
  49.                 {% set main = main|merge([{label: 'Метро' , uri: path('station_list.page', {city: city.uriIdentity})}]) %}
  50.             {% endif %}
  51.             {% set children = main|merge([children|last]) %}
  52.             {% for breadcrumb_item in children %}
  53.                 <li class="{% if loop.last %}last-crumb{% endif %}" property="itemListElement" typeof="ListItem">
  54.                     {% if not loop.last %}
  55.                         <a href="{{ breadcrumb_item.uri }}" property="item" typeof="WebPage"><span property="name">{{ breadcrumb_item.label }}</span></a>
  56.                     {% else %}
  57.                         <span property="name">{{ breadcrumb_item.label }}</span>
  58.                     {% endif %}
  59.                     <meta property="position" content="{{ loop.index }}">
  60.                 </li>
  61.             {% endfor %}
  62.         </ul>
  63.     {% endif %}
  64. {% else %}
  65.     {% if (route == 'profile_list.list_by_city' or route == 'profile_list.list_by_city._pagination')
  66.             and city != default_city() %}
  67.         {#{% 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})}] %}#}
  68.         {% 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})}] %}
  69.         {% set children = main %}
  70.         <ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
  71.             <li property="itemListElement" typeof="ListItem">
  72.                 <a href="{{ (children|first).uri }}" class="std-hover-link" property="item" typeof="WebPage"><span property="name">{{ (children|first).label }}</span></a>
  73.                 <meta property="position" content="0">
  74.             </li>
  75.             <li property="itemListElement" typeof="ListItem">
  76.                 <span property="name">{{ (children|last).label }}</span>
  77.                 <meta property="position" content="1">
  78.             </li>
  79.         </ul>
  80.     {% endif %}
  81. {% endif %}