templates/app/product/index.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2.  
  3. {% block title %}Tous les produits{% endblock %}
  4. {% block body %}
  5.     <div class="container mt-2">
  6.         <div class="row">
  7.             <div class="col-12 header-title">
  8.                 <h1>Nos produits</h1>
  9.             </div>
  10.         </div>
  11.         <div class="row">
  12.             <div class="col-12">
  13.                 {% for label, messages in app.flashes %}
  14.                     {% for message in messages %}
  15.                         <div class="alert alert-{{ label }} alert-dismissible fade show" role="alert">
  16.                             <strong>{{ message }}</strong>
  17.                             <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
  18.                         </div>
  19.                     {% endfor %}
  20.                 {% endfor %}
  21.             </div>
  22.         </div>
  23.         {% if products is defined and products is not empty %}
  24.             <div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
  25.                 {% for product in products %}
  26.                     <div class="col">
  27.                         <div class="card card-product h-100">
  28.                             <div class="row g-0 h-100">
  29.                                 <div class="col-md-6 p-0">
  30.                                     {% if product.picture is not empty and fileExists(product.picture) %}
  31.                                         <img src="{{ asset('uploads/images/' ~ product.picture) }}"
  32.                                              alt="{{ product.title }}"
  33.                                              class="w-100 h-100 object-fit-cover" style="border-radius: 2%;"/>
  34.                                     {% else %}
  35.                                         <img src="{{ asset('images/logo.svg') }}" alt="Default image"
  36.                                              class="w-100 h-100 object-fit-cover" style="border-radius: 2%;">
  37.                                     {% endif %}
  38.                                 </div>
  39.                                 <div class="col-md-6 d-flex flex-column">
  40.                                     <div class="card-body d-flex flex-column h-100">
  41.                                         <h5 class="card-title">{{ product.title }}</h5>
  42.                                         <p class="card-text small flex-grow-1">{{ product.description|u.truncate(80, '...') }}</p>
  43.                                         <div class="mt-auto">
  44.                                             <p class="card-text fw-bold mb-2">{{ product.price|format_currency('EUR') }}</p>
  45.                                             <div class="mb-2">
  46.                                                 {% if product.isCustomizable %}
  47.                                                     <span class="badge bg-success">Personnalisable</span>
  48.                                                 {% else %}
  49.                                                     <span class="badge bg-secondary">Non personnalisable</span>
  50.                                                 {% endif %}
  51.                                             </div>
  52.                                             {% if product.isCustomizable %}
  53.                                                 <button type="button" class="btn btn-sm btn-green w-100"
  54.                                                         data-bs-toggle="modal"
  55.                                                         data-bs-target="#customModal-{{ product.id }}">
  56.                                                     Ajouter au panier
  57.                                                 </button>
  58.                                             {% else %}
  59.                                                 <a href="{{ path('product_add_cart', {'id': product.id }) }}"
  60.                                                    class="btn btn-sm btn-green w-100">Ajouter au panier</a>
  61.                                             {% endif %}
  62.                                         </div>
  63.                                     </div>
  64.                                 </div>
  65.                             </div>
  66.                         </div>
  67.                     </div>
  68.                     {% if product.isCustomizable %}
  69.                         <div class="modal fade" id="customModal-{{ product.id }}" tabindex="-1"
  70.                              aria-labelledby="customModalLabel-{{ product.id }}"
  71.                              aria-hidden="true">
  72.                             <div class="modal-dialog">
  73.                                 <div class="modal-content">
  74.                                     <div class="modal-header">
  75.                                         <h5 class="modal-title" id="customModalLabel-{{ product.id }}">Personnalisation
  76.                                             de votre achat</h5>
  77.                                         <button type="button" class="btn-close" data-bs-dismiss="modal"
  78.                                                 aria-label="Close"></button>
  79.                                     </div>
  80.                                     <form action="{{ path('product_add_cart', {'id': product.id}) }}" method="POST">
  81.                                         <div class="modal-body">
  82.                                             <div class="mb-3">
  83.                                                 <label for="customization-{{ product.id }}" class="form-label">Personnalisation
  84.                                                     :</label>
  85.                                                 <input type="text" class="form-control" name="customization"
  86.                                                        id="customization-{{ product.id }}">
  87.                                             </div>
  88.                                         </div>
  89.                                         <div class="modal-footer">
  90.                                             <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
  91.                                                 Annuler
  92.                                             </button>
  93.                                             <button type="submit" class="btn btn-design">Ajouter au panier</button>
  94.                                         </div>
  95.                                     </form>
  96.                                 </div>
  97.                             </div>
  98.                         </div>
  99.                     {% endif %}
  100.                 {% endfor %}
  101.             </div>
  102.         {% else %}
  103.             <div class="row">
  104.                 <div class="col-12 text-center">
  105.                     <span>Il n'y a pas de produits pour le moment.</span>
  106.                 </div>
  107.             </div>
  108.         {% endif %}
  109.         <div class="navigation my-2">
  110.             {{ knp_pagination_render(products) }}
  111.         </div>
  112.     </div>
  113. {% endblock %}