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 = [{
  15.             label: 'Проститутки ' ~ city.name|geo_name('genitive'), 
  16.             uri: path('profile_list.list_by_city', {city: city.uriIdentity})
  17.         }]%}
  18.         {# {Элитные|Дешевые|Дорогие} #}
  19.         {% set height = profile.personParameters.height|default(0) %}
  20.         {% set minPriceThreshold = isMainCity ? 3000 : 2000 %}
  21.         {% set maxPriceThreshold = isMainCity ? 15000 : 10000 %}
  22.         {% set isProfileCheapest = (profile.apartmentsPricing.oneHourPrice|default(0) >= minPriceThreshold) or
  23.                                     (profile.takeOutPricing.oneHourPrice|default(0) >= minPriceThreshold) %}
  24.         {% set isEliteProfile = height >= 170 and isProfileCheapest %}
  25.         {% set isProfileHighCost = (profile.apartmentsPricing.oneHourPrice|default(0) >= maxPriceThreshold) or
  26.                                     (profile.takeOutPricing.oneHourPrice|default(0) >= maxPriceThreshold) %}
  27.         {% if isEliteProfile %} 
  28.             {# === Определяем, является ли профиль элитным === #}
  29.             {% set outputLink = path('profile_list.list_price_elite', {'city': city.uriIdentity}) %}
  30.             {% set main = main|merge([{
  31.                 label: 'Элитные проститутки', 
  32.                 uri: outputLink
  33.             }]) %}
  34.         {% elseif isProfileCheapest %}
  35.             {# === Определяем, является ли профиль дешёвым === #}
  36.             {% set outputLink = path('profile_list.list_price_low', {'city': city.uriIdentity}) %}
  37.             {% set main = main|merge([{
  38.                 label: 'Дешевые проститутки', 
  39.                 uri: outputLink
  40.             }]) %}
  41.         {% elseif isProfileHighCost %}
  42.             {# === Определяем, является ли профиль Дорогим === #}
  43.             {% set outputLink = path('profile_list.list_price_high', {'city': city.uriIdentity}) %}
  44.             {% set main = main|merge([{
  45.                 label: 'Дорогие проститутки', 
  46.                 uri: outputLink
  47.             }]) %}
  48.         {% endif %}
  49.         {# {Молодые|Взрослые} #}
  50.         {% set ageYoung = profile.personParameters.age < 22 %}
  51.         {% set outputAge = ageYoung ? 'Молодые' :
  52.                             (profile.personParameters.age > 29 ? 'Взрослые' : '') %}
  53.         {% if outputAge %} 
  54.             {% set outputAgeLink = ageYoung ? 
  55.                     path('profile_list.list_age_young', {'city': city.uriIdentity}) : 
  56.                     path('profile_list.list_age_older_than', {'city': city.uriIdentity}) %}
  57.             {% set main = main|merge([{
  58.                 label: outputAge ~ ' проститутки', 
  59.                 uri: outputAgeLink
  60.             }]) %}
  61.         {% endif %}
  62.         {# Проверенное фото #}
  63.         {% if profile.approved %} 
  64.             {% set main = main|merge([{
  65.                 label: 'Проверенное фото', 
  66.                 uri: path('profile_list.list_approved', {'city': city.uriIdentity})
  67.             }]) %}
  68.         {% endif %}
  69.         {% if isMainCity %}
  70.             {% if station and station.district and station.district.county %}
  71.                 {% 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})}]) %}
  72.             {% endif %}
  73.              {% if station and station.district %}
  74.                 {% set main = main|merge([{label: station.district.name|trans, uri: path('profile_list.list_by_district', {city: city.uriIdentity, district: station.district.uriIdentity})}]) %}
  75.             {% endif %}
  76.             {% if profile and station %}
  77.                 {% set main = main|merge([{label: station.name|trans , uri: path('profile_list.list_by_station', {city: city.uriIdentity, station: station.uriIdentity})}]) %}
  78.             {% endif %}
  79.         {% endif %}
  80.      
  81.         {% set children = main|merge([children|last]) %}
  82.         <ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
  83.             {% for breadcrumb_item in children %}
  84.                 <li class="{% if loop.last %}last-crumb{% endif %}" property="itemListElement" typeof="ListItem">
  85.                     {% if not loop.last %}
  86.                         <a href="{{ breadcrumb_item.uri }}" property="item" typeof="WebPage"><span property="name">{{ breadcrumb_item.label }}</span></a>
  87.                     {% else %}
  88.                         <span property="name">{{ breadcrumb_item.label }}{{ profile.personParameters.age ? ', ' ~ profile.personParameters.age|plural('год') : '' }} ID {{ profile.id }}</span>
  89.                     {% endif %}
  90.                     <meta property="position" content="{{ loop.index }}">
  91.                 </li>
  92.             {% endfor %}
  93.         </ul>
  94.     {% else %}
  95.         {%- set isProfileList = ('profile_list.' in route) and ('_pagination' in route) -%}
  96.         <ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
  97.             {# Делаем првый элемент "Главная", второй - город #}
  98.             {#{% 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})}] %}#}
  99.             {% 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})}] %}
  100.             {% if 'profile_list.list_by_station' in route %}
  101.                 {% set main = main|merge([{label: 'Метро' , uri: path('station_list.page', {city: city.uriIdentity})}]) %}
  102.             {% endif %}
  103.             {# Только для листинга С ПАГИНАЦИЕЙ #}
  104.             {%- if isProfileList -%}
  105.                 {% set routeParams = app.request.attributes.get('_route_params') %}
  106.                 {% set children = main|merge([{label: children|last.name, uri: path(route|replace({'._pagination': ''}), routeParams)}]) %}
  107.                 {% set children = children|merge([{label: 'Страница ' ~ app.request.get('page')}]) %}
  108.             {%- else -%}
  109.                 {% set children = main|merge([children|last]) %}
  110.             {% endif %}
  111.             {% for breadcrumb_item in children %}
  112.                 <li class="{% if loop.last %}last-crumb{% endif %}" property="itemListElement" typeof="ListItem">
  113.                     {% if not loop.last and breadcrumb_item.uri is defined %}
  114.                         <a href="{{ breadcrumb_item.uri }}" property="item" typeof="WebPage"><span property="name">{{ breadcrumb_item.label }}</span></a>
  115.                     {% else %}
  116.                         <span {{ breadcrumb_item.classname is defined ? 'class=' ~ breadcrumb_item.classname : '' }} property="name">{{ breadcrumb_item.label }}</span>
  117.                     {% endif %}
  118.                     <meta property="position" content="{{ loop.index }}">
  119.                 </li>
  120.             {% endfor %}
  121.         </ul>
  122.     {% endif %}
  123. {% else %}
  124.     {% if (route == 'profile_list.list_by_city' or route == 'profile_list.list_by_city._pagination')
  125.             and city != default_city() %}
  126.         {#{% 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})}] %}#}
  127.         {% 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})}] %}
  128.         {% set children = main %}
  129.         <ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
  130.             <li property="itemListElement" typeof="ListItem">
  131.                 <a href="{{ (children|first).uri }}" class="std-hover-link" property="item" typeof="WebPage"><span property="name">{{ (children|first).label }}</span></a>
  132.                 <meta property="position" content="0">
  133.             </li>
  134.             <li property="itemListElement" typeof="ListItem">
  135.                 <span property="name">{{ (children|last).label }}</span>
  136.                 <meta property="position" content="1">
  137.             </li>
  138.         </ul>
  139.     {% endif %}
  140. {% endif %}