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