templates/_menu/breadcrumbs.html.twig line 1

Open in your IDE?
  1. {% set route = app.request.get('_route') %}
  2. {% set city = app.request.get('city') ?? null %}
  3. {% set items = item.children %}
  4. {% set crumbHomepage = items|slice(0, 1)|first %}
  5. {% set crumbHomepage = {label: crumbHomepage ? crumbHomepage.label : '', uri: path('homepage')} %}
  6. {% if 'profile_preview.page' in route %}
  7.     {% set profile = app.request.get('profile') %}
  8.     {% set profileItem = {label: 'Индивидуалка ' ~ profile.name|trans ~ ' (' ~ profile.personParameters.age ~ ')', uri: '' } %}
  9.     {% if (city.id == default_city().id) %}
  10.         {% if profile.stations|length > 0 %}
  11.             {% set profileStation = profile.stations[0] %}
  12.             {% set items = [
  13.                 crumbHomepage,
  14.                 {label: 'Метро СПБ', uri: path('station_list.page', {city: city.uriIdentity})},
  15.                 {label: 'Проститутки ' ~ profileStation.name|trans, uri: path('profile_list.list_by_station', {city: city.uriIdentity, station: profileStation.uriIdentity})},
  16.                 profileItem
  17.             ] %}
  18.         {% else %}
  19.             {% set items = [
  20.                 crumbHomepage,
  21.                 profileItem
  22.             ] %}
  23.         {% endif %}
  24.     {% else %}
  25.         {% set items = [
  26.             crumbHomepage,
  27.             {label: city.name|trans, uri: path('profile_list.list_by_city', {city: city.uriIdentity})},
  28.             profileItem
  29.         ] %}
  30.     {% endif %}
  31. {% elseif 'profile_list.list_by_station' in route %}
  32.     {% set items = [
  33.         crumbHomepage,
  34.         {label: 'Метро СПБ', uri: path('station_list.page', {city: city.uriIdentity})},
  35.         items|slice(1, 1)|first
  36.     ] %}
  37. {% elseif 'profile_list.list_by_provided_service' in route and (city.id != default_city().id) %}
  38.     {% set items = [
  39.         crumbHomepage,
  40.         {label: city.name|trans, uri: path('profile_list.list_by_city', {city: city.uriIdentity})},
  41.         items|slice(1, 1)|first
  42.     ] %}
  43. {% elseif 'profile_list.list_by_city' in route and (city.id != default_city().id) %}
  44.     {% set items = [
  45.         crumbHomepage,
  46.         {label: city.name|trans}
  47.     ] %}
  48. {% elseif lastCrumbLabelInArticle is defined %}
  49.     {% if lastCrumbLabelInArticle == 'Статьи' %}
  50.         {% set items = [
  51.             {label: 'Главная', uri: path('homepage')},
  52.             {label: 'Статьи'}
  53.         ] %}
  54.     {% else %}
  55.         {% set items = [
  56.             {label: 'Главная', uri: path('homepage')},
  57.             {label: 'Статьи', uri: path('static_page.articles')},
  58.             {label: lastCrumbLabelInArticle}
  59.         ] %}
  60.     {% endif %}
  61. {% endif %}
  62. {% if items|length > 1 %}
  63.     <ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
  64.         {% for breadcrumb_item in items %}
  65.             <li class="{% if loop.last %}last-crumb{% endif %}" property="itemListElement" typeof="ListItem">
  66.                 {% if not loop.last %}
  67.                     <a href="{{ breadcrumb_item.uri }}" property="item" typeof="WebPage"><span property="name">{{ breadcrumb_item.label|trans({}, 'breadcrumbs') }}</span></a>
  68.                 {% else %}
  69.                     <span property="name">{{ breadcrumb_item.label }}</span>
  70.                 {% endif %}
  71.                 <meta property="position" content="{{ loop.index }}">
  72.             </li>
  73.         {% endfor %}
  74.     </ul>
  75. {% endif %}