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.         {%- set isProfileList = ('profile_list.' in route) and ('_pagination' in route) -%}
  45.         <ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
  46.             {# Делаем првый элемент "Главная", второй - город #}
  47.             {#{% 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})}] %}#}
  48.             {% 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})}] %}
  49.             {% if 'profile_list.list_by_station' in route %}
  50.                 {% set main = main|merge([{label: 'Метро' , uri: path('station_list.page', {city: city.uriIdentity})}]) %}
  51.             {% endif %}
  52.             {# Только для листинга С ПАГИНАЦИЕЙ #}
  53.             {%- if isProfileList -%}
  54.                 {% set children = main|merge([{label: children|last.name, classname: 'pre-last-crumb'}]) %}
  55.                 {% set children = children|merge([{label: 'Страница ' ~ app.request.get('page')}]) %}
  56.             {%- else -%}
  57.                 {% set children = main|merge([children|last]) %}
  58.             {% endif %}
  59.             {% for breadcrumb_item in children %}
  60.                 <li class="{% if loop.last %}last-crumb{% endif %}" property="itemListElement" typeof="ListItem">
  61.                     {% if not loop.last and breadcrumb_item.uri is defined %}
  62.                         <a href="{{ breadcrumb_item.uri }}" property="item" typeof="WebPage"><span property="name">{{ breadcrumb_item.label }}</span></a>
  63.                     {% else %}
  64.                         <span {{ breadcrumb_item.classname is defined ? 'class=' ~ breadcrumb_item.classname : '' }} property="name">{{ breadcrumb_item.label }}</span>
  65.                     {% endif %}
  66.                     <meta property="position" content="{{ loop.index }}">
  67.                 </li>
  68.             {% endfor %}
  69.         </ul>
  70.     {% endif %}
  71. {% else %}
  72.     {% if (route == 'profile_list.list_by_city' or route == 'profile_list.list_by_city._pagination')
  73.             and city != default_city() %}
  74.         {#{% 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})}] %}#}
  75.         {% 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})}] %}
  76.         {% set children = main %}
  77.         <ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
  78.             <li property="itemListElement" typeof="ListItem">
  79.                 <a href="{{ (children|first).uri }}" class="std-hover-link" property="item" typeof="WebPage"><span property="name">{{ (children|first).label }}</span></a>
  80.                 <meta property="position" content="0">
  81.             </li>
  82.             <li property="itemListElement" typeof="ListItem">
  83.                 <span property="name">{{ (children|last).label }}</span>
  84.                 <meta property="position" content="1">
  85.             </li>
  86.         </ul>
  87.     {% endif %}
  88. {% endif %}