templates/vinyl/index.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}{{ 'vinyls.title'|trans }}{% endblock %}
  3. {% block meta %}
  4.     <meta name="description" content="Mazykka Vinyles {% if search %}{{ ('navigation.' ~ search|lower)|trans|default(search) }}{% endif %}, {% for vinyl in vinyls %} {{ vinyl.designation }}{% if not loop.last %},{% endif %} {% endfor %}">
  5.     <meta name="keywords" content="Mazykka, vinyles, {% if vinyls|length > 0 %} {% for style in vinyls[0].styles %} {{ style.name }}{% if not loop.last %},{% endif %} {% endfor %} {% endif %}"> 
  6.     <meta property="og:url" content="path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params'))" />
  7. {% endblock %}
  8. {% block hero %}
  9.     {% if search %}
  10.         <h1 class="text-center">{{ 'vinyls.title'|trans }} <span> {{ ('navigation.' ~ search|lower)|trans|default(search)|capitalize }} </span></h1>
  11.     {% else %}
  12.         <h1 class="text-center"><span>{{ 'vinyls.all_vinyls'|trans }}</span></h1>
  13.     {% endif %}
  14. {% endblock %}
  15. {% block body %}
  16.     <section class="vinyls_list">
  17.         <div class="">
  18.             <div class="filter__item">
  19.                 <div class="row">
  20.                     <div class="col-lg-2 col-md-3 col-sm-3 col-6">
  21.                         <div>
  22.                             {% set route = app.request.attributes.get('_route')  %}
  23.                             {% if app.request.attributes.get('stylename') %}
  24.                                 {% set route = route  ~ "/" ~ app.request.attributes.get('stylename')  %}
  25.                             {% endif %}
  26.                             <select class="filter__sort form-select">
  27.                                 <option value="{{ path(app.request.attributes.get('_route'), {'stylename': app.request.attributes.get('stylename')}) }}">{{ 'vinyls.sort_by'|trans }}</option>
  28.                                 <option {% if sort == "price-asc" %}selected="selected"{% endif %} value="{{ path(app.request.attributes.get('_route'), app.request.query.all) }}{% if app.request.attributes.get('stylename') %}/{{ app.request.attributes.get('stylename') }}{% endif %}{% if app.request.query.all %}&{% else %}?{% endif %}page={{ page }}&sort=price&direction=asc">{{ 'vinyls.price_asc'|trans }}</option>
  29.                                 <option {% if sort == "price-desc" %}selected="selected"{% endif %} value="{{ path(app.request.attributes.get('_route'), app.request.query.all) }}{% if app.request.attributes.get('stylename') %}/{{ app.request.attributes.get('stylename') }}{% endif %}{% if app.request.query.all %}&{% else %}?{% endif %}page={{ page }}&sort=price&direction=desc">{{ 'vinyls.price_desc'|trans }}</option>
  30.                                 <option {% if sort == "year-asc" %}selected="selected"{% endif %} value="{{ path(app.request.attributes.get('_route'), app.request.query.all) }}{% if app.request.attributes.get('stylename') %}/{{ app.request.attributes.get('stylename') }}{% endif %}{% if app.request.query.all %}&{% else %}?{% endif %}page={{ page }}&sort=year&direction=asc">{{ 'vinyls.year_asc'|trans }}</option>
  31.                                 <option {% if sort == "year-desc" %}selected="selected"{% endif %} value="{{ path(app.request.attributes.get('_route'), app.request.query.all) }}{% if app.request.attributes.get('stylename') %}/{{ app.request.attributes.get('stylename') }}{% endif %}{% if app.request.query.all %}&{% else %}?{% endif %}page={{ page }}&sort=year&direction=desc">{{ 'vinyls.year_desc'|trans }}</option>
  32.                             </select>
  33.                         </div>
  34.                     </div>
  35.                     <div class="col-lg-10 col-md-6 col-sm-6 col-6 d-flex align-items-center">
  36.                         <div class="filter__found text-start">
  37.                             <h4>
  38.                                 <span>{{ vinyls.getTotalItemCount }}</span> {% if vinyls.getTotalItemCount > 1 %}{{ 'vinyl_pages.vinyl_plural'|trans }}{% else %}{{ 'vinyl_pages.vinyl_singular'|trans }}{% endif %} {% if search %}{{ ('navigation.' ~ search|lower)|trans|default(search) }}{% endif %}
  39.                             </h4>
  40.                         </div>
  41.                     </div>
  42.                 </div>
  43.             </div>
  44.             <div class="row">
  45.                 {% for vinyl in vinyls %}
  46.                     <div class="col-lg-3 col-md-6 col-sm-6 mt-4">
  47.                         <div class="product__item d-flex flex-column h-100 bg-white rounded p-2 {% if vinyl.quantity > 0 %}box-green{% else %}box-red{% endif %}">
  48.                             <div class="product__item__pic text-center">
  49.                                 {% if vinyl.img != null %}
  50.                                     <a href="{{ path('vinyls_show', {'slug': vinyl.slug}) }}">
  51.                                         <img src="{{ asset('uploads/vinyles/' ~ vinyl.slug ~ '/' ~ vinyl.img) }}" class="card-img-top" alt="{{ vinyl.designation }} - vinyle {{ vinyl.styles[0].name }}">
  52.                                     </a>
  53.                                 {% else %}
  54.                                     <a href="{{ path('vinyls_show', {'slug': vinyl.slug}) }}">
  55.                                         <img src="{{ asset('uploads/vinyles/default_vinyl.png') }}" class="card-img-top" alt="{{ vinyl.designation }} - vinyle {{ vinyl.styles[0].name }}">
  56.                                     </a>
  57.                                 {% endif %}
  58.                             </div>
  59.                             <div class="product__item__text">
  60.                                 <h6>
  61.                                     <a href="{{ path('vinyls_show', {'slug': vinyl.slug}) }}">{{ vinyl.designation }}</a>
  62.                                 </h6>
  63.                                 {% set i = 0 %}
  64.                                 {% for style in vinyl.styles %} 
  65.                                     {% set i = i + 1 %}
  66.                                     <a href="{{ path('vinyls_search', {'styles': [style.id]}) }}">{{ style.name|capitalize }}</a> 
  67.                                     {% if i < vinyl.styles|length %} | {% endif %}
  68.                                 {% endfor %}
  69.                                 <div>
  70.                                     <div class="badge text-bg-secondary">
  71.                                         <p>{{ vinyl.state|capitalize }}</p>
  72.                                     </div>
  73.                                 </div>
  74.                                 {% if vinyl.promo and vinyl.promo > 0 %}
  75.                                     <h5> <del class="fw-normal fs-6 me-2">{{ vinyl.price|number_format(2) }} €</del>  <span class="success">{{ vinyl.promo|number_format(2) }} €{% if vinyl.state == "neuf" %} <span class="vat">{{ 'vinyl_pages.ttc'|trans }}</span>{% endif %}</span></h5>
  76.                                 {% else %}
  77.                                     <h5>{{ vinyl.price|number_format(2) }} €{% if vinyl.state == "neuf" %} <span class="vat">{{ 'vinyl_pages.ttc'|trans }}</span>{% endif %}</h5>
  78.                                 {% endif %}
  79.                             </div>
  80.                             <div class="tracklist mt-4">
  81.                                 {% for track in vinyl.tracks %}
  82.                                     <audio controls src="{{ asset('uploads/vinyles/' ~ vinyl.slug ~ '/' ~ track.filename ~ '.mp3' ) }}" controlslist="nodownload" preload="none">
  83.                                         {{ 'vinyl_pages.browser_no_support'|trans }}
  84.                                         <code>{{ 'vinyl_pages.audio_element'|trans }}</code>
  85.                                         {{ 'vinyl_pages.element'|trans }}
  86.                                     </audio>
  87.                                 {% endfor %}
  88.                             </div>
  89.                             <div class="mt-auto text-center">
  90.                                 {% if vinyl.quantity > 0 %}
  91.                                     {% if app.user %}
  92.                                         <a href="{{ path('cart_add', {'id': vinyl.id}) }}" class="btn btn-primary mt-2 w-100">
  93.                                             <i class="fa fa-shopping-cart" aria-hidden="true"></i>
  94.                                         </a>
  95.                                     {% else %}
  96.                                         <button type="button" class="btn btn-primary mt-2 w-100" data-bs-toggle="modal" data-bs-target="#needConnexionModal">
  97.                                             <i class="fa fa-shopping-cart" aria-hidden="true"></i>
  98.                                         </button>
  99.                                     {% endif %}
  100.                                 {% else %}
  101.                                     <h3 class="red">{{ 'vinyl_pages.out_of_stock'|trans }}</h3>
  102.                                 {% endif %}
  103.                                 
  104.                             </div>
  105.                         </div>
  106.                     </div>
  107.                 {% endfor %}
  108.             </div>
  109.             <div class="pagination my-3 d-flex justify-content-center">
  110.                 {{ knp_pagination_render(vinyls, '@KnpPaginator/Pagination/twitter_bootstrap_v4_pagination.html.twig') }}
  111.             </div>
  112.         
  113.         </div>
  114.     </section>
  115. {% endblock %}
  116. {% block javascript %}{% endblock %}