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 = 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 ageOld    =  profile.personParameters.age > 35 %}
  58.         {% set outputAge =  ageYoung ? 'Молодые' :
  59.                             ageOld ? 'Старые' : 'Взрослые' %}
  60.         {% set outputAgeLink =  ageYoung ? path('profile_list.list_age_young', {'city': city.uriIdentity}) : 
  61.                                 ageOld ? path('profile_list.list_grandmothers', {'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.         {# Проверенное фото #}
  68.         {% if profile.approved %} 
  69.             {% set main = main|merge([{
  70.                 label: 'Проверенное фото', 
  71.                 uri: path('profile_list.list_approved', {'city': city.uriIdentity})
  72.             }]) %}
  73.         {% endif %}
  74.         {% set children = main|merge([children|last]) %}
  75.         <ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
  76.             {% for breadcrumb_item in children %}
  77.                 <li class="{% if loop.last %}last-crumb{% endif %}" property="itemListElement" typeof="ListItem">
  78.                     {% if not loop.last %}
  79.                         <a href="{{ breadcrumb_item.uri }}" property="item" typeof="WebPage"><span property="name">{{ breadcrumb_item.label }}</span></a>
  80.                     {% else %}
  81.                         <span property="name">{{ breadcrumb_item.label }}{{ profile.personParameters.age ? ', ' ~ profile.personParameters.age|plural('год') : '' }} ID {{ profile.id }}</span>
  82.                     {% endif %}
  83.                     <meta property="position" content="{{ loop.index }}">
  84.                 </li>
  85.             {% endfor %}
  86.         </ul>
  87.     {% else %}
  88.         {%- set isProfileList = ('profile_list.' in route) and ('_pagination' in route) -%}
  89.         <ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
  90.             {# Делаем првый элемент "Главная", второй - город #}
  91.             {#{% 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})}] %}#}
  92.             {% 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})}] %}
  93.             {% if 'profile_list.list_by_station' in route %}
  94.                 {% set main = main|merge([{label: 'Метро' , uri: path('station_list.page', {city: city.uriIdentity})}]) %}
  95.             {% endif %}
  96.             {# Только для листинга С ПАГИНАЦИЕЙ #}
  97.             {%- if isProfileList -%}
  98.                 {% set routeParams = app.request.attributes.get('_route_params')|merge({'page': null}) %}
  99.                 {% set children = main|merge([{label: children|last.name, uri: path(route|replace({'._pagination': ''}), routeParams)}]) %}
  100.                 {% set children = children|merge([{label: 'Страница ' ~ app.request.get('page')}]) %}
  101.             {%- else -%}
  102.                 {% set children = main|merge([children|last]) %}
  103.             {% endif %}
  104.             {% for breadcrumb_item in children %}
  105.                 <li class="{% if loop.last %}last-crumb{% endif %}" property="itemListElement" typeof="ListItem">
  106.                     {% if not loop.last and breadcrumb_item.uri is defined %}
  107.                         <a href="{{ breadcrumb_item.uri }}" property="item" typeof="WebPage"><span property="name">{{ breadcrumb_item.label }}</span></a>
  108.                     {% else %}
  109.                         <span {{ breadcrumb_item.classname is defined ? 'class=' ~ breadcrumb_item.classname : '' }} property="name">{{ breadcrumb_item.label }}</span>
  110.                     {% endif %}
  111.                     <meta property="position" content="{{ loop.index }}">
  112.                 </li>
  113.             {% endfor %}
  114.         </ul>
  115.     {% endif %}
  116. {% else %}
  117.     {% if (route == 'profile_list.list_by_city' or route == 'profile_list.list_by_city._pagination')
  118.             and city != default_city() %}
  119.         {#{% 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})}] %}#}
  120.         {% 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})}] %}
  121.         {% set children = main %}
  122.         <ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
  123.             <li property="itemListElement" typeof="ListItem">
  124.                 <a href="{{ (children|first).uri }}" class="std-hover-link" property="item" typeof="WebPage"><span property="name">{{ (children|first).label }}</span></a>
  125.                 <meta property="position" content="0">
  126.             </li>
  127.             <li property="itemListElement" typeof="ListItem">
  128.                 <span property="name">{{ (children|last).label }}</span>
  129.                 <meta property="position" content="1">
  130.             </li>
  131.         </ul>
  132.     {% endif %}
  133. {% endif %}