themes/BootstrapChildTheme/SyliusShopBundle/views/Product/Index/_sorting.html.twig line 1

Open in your IDE?
  1. {% if resources.data.nbResults > 0 %}
  2. {% set route = app.request.attributes.get('_route') %}
  3. {% set route_parameters = app.request.attributes.get('_route_params')|merge(app.request.query.all) %}
  4. {% set criteria = app.request.query.get('criteria', {}) %}
  5. {% set oldest_first_path = path(route, route_parameters|merge({'sorting': {'createdAt': 'asc'}, 'criteria': criteria})) %}
  6. {% set newest_first_path = path(route, route_parameters|merge({'sorting': {'createdAt': 'desc'}, 'criteria': criteria})) %}
  7. {% if app.request.query.get('sorting') is empty %}
  8.     {% set current_sorting_label = 'sylius.ui.published_newest_first'|trans|lower %}
  9. {% elseif app.request.query.get('sorting').name is defined and app.request.query.get('sorting').name == 'asc'%}
  10.     {% set current_sorting_label = 'sylius.ui.from_a_to_z'|trans|lower %}
  11. {% elseif app.request.query.get('sorting').name is defined and app.request.query.get('sorting').name == 'desc'%}
  12.     {% set current_sorting_label = 'sylius.ui.from_z_to_a'|trans|lower %}
  13. {% elseif app.request.query.get('sorting').createdAt is defined and app.request.query.get('sorting').createdAt == 'desc'%}
  14.     {% set current_sorting_label = 'sylius.ui.published_newest_first'|trans|lower %}
  15. {% elseif app.request.query.get('sorting').createdAt is defined and app.request.query.get('sorting').createdAt == 'asc'%}
  16.     {% set current_sorting_label = 'sylius.ui.published_oldest_first'|trans|lower %}
  17. {% elseif app.request.query.get('sorting').price is defined and app.request.query.get('sorting').price == 'asc'%}
  18.     {% set current_sorting_label = 'sylius.ui.cheapest_first'|trans|lower %}
  19. {% elseif app.request.query.get('sorting').price is defined and app.request.query.get('sorting').price == 'desc' %}
  20.     {% set current_sorting_label = 'sylius.ui.most_expensive_first'|trans|lower %}
  21. {% endif %}
  22.     <div class="ui right floated small header">
  23.         <div class="content">
  24.             {{ 'sylius.ui.sort'|trans }}
  25.             <div class="ui inline dropdown">
  26.                 <div class="text">{{ current_sorting_label }}</div>
  27.                 <i class="dropdown icon"></i>
  28.                 <div class="menu">
  29.                     <a class="item" href="{{ newest_first_path }}" data-text="{{ 'app.pages.product.index.decreasing_publishing_date'|trans }}">{{ 'app.pages.product.index.decreasing_publishing_date'|trans }}</a>
  30.                     <a class="item" href="{{ oldest_first_path }}" data-text="{{ 'app.pages.product.index.increasing_publishing_date'|trans }}">{{ 'app.pages.product.index.increasing_publishing_date'|trans }}</a>
  31.                 </div>
  32.             </div>
  33.         </div>
  34.     </div>
  35. {% endif %}