templates/produit/fiche_produit.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %} {{ parent() }} |  {{ produit.nom }} {% endblock %}
  3. {% block stylesheets %}
  4.     <link rel="stylesheet" href="{{ asset('css/fiche_produit.css') }}">
  5. {% endblock %}
  6. {% block content %}
  7.   {% set categories = app.session.get('categories') %}
  8.     <div itemscope itemtype="https://schema.org/Product" class="wrapper col-12 d-flex flex-lg-row flex-column ">
  9.         <meta itemprop="url" content="https://www.lebiodelo.com{{ app.request.getPathInfo }}">
  10.         <div class="col-lg-6 col-12">
  11.             <div id="carouselExampleIndicators" class="carousel carousel-dark slide" data-bs-ride="carousel">
  12.                 <div class="carousel-indicators">
  13.                     {% for photo in produit.photoProduits %}
  14.                     
  15.                         {% if photo.position == 1 %}
  16.                         <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="{{ photo.position -1 }}" class="carousselIndiator active" aria-current="true" aria-label="Slide ~{{ photo.position}}"></button>
  17.                             
  18.                         {% else %}
  19.                         <button type="button" data-bs-target="#carouselExampleIndicators"  data-bs-slide-to="{{ photo.position -1 }}"   class="carousselIndicator" aria-label="Slide ~{{ photo.position}}"></button>
  20.                             
  21.                         {% endif %}
  22.                         
  23.                     {% endfor %}
  24.                 </div>
  25.                 <div class="carousel-inner">
  26.                     {% for photo in produit.photoProduits %}
  27.                         {% if photo.position == 1 %}
  28.                         <div class="carousel-item active">
  29.                             <img itemprop="image" class="d-block mx-auto my-auto" src="{{ asset("img/photoProduitUpload/" ~  photo.nom ) }}" alt="slide "~{{ photo.position }}>
  30.                         </div>
  31.                         {% else %}
  32.                         <div class="carousel-item">
  33.                         <img class="d-block" src="{{ asset("img/photoProduitUpload/" ~  photo.nom ) }}"  alt="slide "~{{ photo.position }}>
  34.                     </div>
  35.                         {% endif %}
  36.                         
  37.                     {% endfor %}
  38.     
  39.                 </div>
  40.                 <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
  41.                     <span class="carousel-control-prev-icon" aria-hidden="true"></span>
  42.                     <span class="visually-hidden">Previous</span>
  43.                 </button>
  44.                 <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
  45.                     <span class="carousel-control-next-icon" aria-hidden="true"></span>
  46.                     <span class="visually-hidden">Next</span>
  47.                 </button>
  48.             </div>
  49.         </div>
  50.         
  51.         <div class=" col-lg-5 col-10 mx-auto d-flex flex-column justify-centent-start">
  52.             <div  class="data_content">
  53.                 <div class="data d-flex flex-column justify-content-start align-items-start">
  54.                 
  55.                     <nav itemprop='breadcrumb' aria-label="Breadcrumb" class="breadcrumb d-md-block d-none">
  56.                         <ul>
  57.                             <li><a href="{{ path('accueil') }}">ACCUEIL</a></li>
  58.                             <li><a href="{{ path('catalogue') }}"> PRODUITS</a></li>
  59.                             <li><a href="{{ path("categorie" , {'id' : produit.categorie.id}) }}"> {{ produit.categorie.nom|upper }}</a></li>
  60.                             <li><span aria-current="page"> {{ produit.nom|upper}} </span></li>
  61.                         </ul>
  62.                     </nav>
  63.                     <h1 itemprop="name" class='nom-produit mt-5'>{{  produit.nom|upper }} -  {{ produit.prixPubTtc|number_format(2,',')  }} EUR</h1>
  64.                     <br>
  65.                     <br>
  66.         
  67.                     
  68.                     <p itemprop="offers" itemscope itemtype="https://schema.org/Offer" class="prix"></p>
  69.             
  70.             
  71.                 </div>
  72.                 <form action="{{ path('panier_ajouter') }}" method="post">
  73.                             
  74.                         <input type="hidden" name="id" value ="{{ produit.id }}">
  75.                         <p itemprop="slogan" class="description">{{ produit.description|raw}}</p>
  76.                         <br>
  77.                             
  78.                         <p id='matieres' class=" mx-auto detail">{{ produit.matiere}}</p>
  79.                         <br>
  80.                         <p id='matieres' class=" mx-auto detail">{{ produit.motif}}</p>
  81.                         <br>
  82.                         <p> <img src="{{ asset('img/icones/bio.jpg') }}" style="width: 100px;" alt=""> Produits issus de l’Agriculture Biologique, certifiés par Ecocert. </p>
  83.                             
  84.                         <p id='tailles' class=" mx-auto detail">{{ produit.taille}}</p>
  85.                     
  86.                             
  87.                             <div class="col-12 d-flex">
  88.                                     <div class=' col-4 d-flex  justify-content-start my-3'>
  89.                                         <div class="input-group">
  90.                                             <label id="label_qty" class ='my-auto' for="qty">Quantité</label>
  91.                                         
  92.                                             <input class=" mx-auto "  style="border-color:#DDD;" id= "qty" type="number" name="qty" id="qty" min="1" max="10" step="1" value="1">
  93.                                         </div>
  94.                                     </div>
  95.                             
  96.                     
  97.                             <button type="submit" class="col-8 btn my-3 ">AJOUTER AU PANIER</button>
  98.                             </div>
  99.                     
  100.                     
  101.                 
  102.                     
  103.                 </form>
  104.                 
  105.              
  106.             </div>
  107.         </div>
  108.     </div>
  109.     
  110.     <textarea hidden class='photo2js' name="" id="" cols="30" rows="10">{{ photos }}</textarea>
  111. {% endblock %}
  112. {% block javascripts %}
  113.     <script>// expension des div Taille, matière et entretien( code à réduire)
  114.         function expandTaille(element){
  115.             let expander = element.getAttribute('expand')
  116.             let elt = document.querySelector('#tailles')
  117.             if (expander == '+') {
  118.                 elt.setAttribute('class','d-block')
  119.                 element.setAttribute('expand','-')
  120.                 element.innerHTML = '<i class="far fa-caret-square-up"></i>'
  121.             }else {
  122.                 elt.setAttribute('class','d-none')
  123.                 element.setAttribute('expand','+')
  124.                 element.innerHTML = '<i class="far fa-caret-square-down">'
  125.             }
  126.         }
  127.         function expandMatiere(element){
  128.             let expander = element.getAttribute('expand')
  129.             let elt = document.querySelector('#matieres')
  130.             if (expander == '+') {
  131.                 elt.setAttribute('class','d-block')
  132.                 element.setAttribute('expand','-')
  133.                 element.innerHTML = '<i class="far fa-caret-square-up"></i>'
  134.             }else {
  135.                 elt.setAttribute('class','d-none')
  136.                 element.setAttribute('expand','+')
  137.                 element.innerHTML = '<i class="far fa-caret-square-down">'
  138.             }
  139.         }
  140.         function expandEntretien(element){    
  141.             let expander = element.getAttribute('expand')
  142.             let elt = document.querySelector('#entretien')
  143.             if (expander == '+') {
  144.                 elt.setAttribute('class','d-block')
  145.                 element.setAttribute('expand','-')
  146.                 element.innerHTML = '<i class="far fa-caret-square-up"></i>'
  147.             }else {
  148.                 elt.setAttribute('class','d-none')
  149.                 element.setAttribute('expand','+')
  150.                 element.innerHTML = '<i class="far fa-caret-square-down">'
  151.             }
  152.         }
  153.     </script>  
  154.     <script>// bootstap caroussel
  155.         $(document).ready(function () {
  156.         $('.carousel').carousel({
  157.         interval: false,
  158.         keyboad: true,
  159.         touch:true
  160.         })
  161.         //$('.carousel').bcSwipe({ threshold: 50 });
  162.         });
  163.     </script>
  164.     <script>// vignettes photos dans les indicateurs du caroussel
  165.         let indicator =document. querySelector('.carousel-indicators')
  166.         let indicators = indicator.childNodes
  167.         let photos = JSON.parse(document.querySelector('.photo2js').value)
  168.         let indicatorsArray= Array.from(indicators)
  169.         let cheminPhoto = "{{ asset('img/photoProduitUpload/') }}"
  170.         indicatorsArray.pop()
  171.         for(i=0; i < indicatorsArray.length; i++ ){
  172.             if(i%2 !== 0){
  173.                 var n=(i+1)/2
  174.                     if (2* n< (indicatorsArray.length+1)){    
  175.                             elt =indicatorsArray [i]
  176.                             elt.style.backgroundImage = 'url('+cheminPhoto+photos[n-1]+')'
  177.                     }
  178.             }        
  179.         }
  180.     </script>
  181.     
  182.     <script> // Bootstrap Carousel Swipe v1.1 not used
  183.         /**
  184.         * Bootstrap Carousel Swipe v1.1
  185.         *
  186.         * jQuery plugin to enable swipe gestures on Bootstrap 3 carousels.
  187.         * Examples and documentation: https://github.com/maaaaark/bcSwipe
  188.         *
  189.         * Licensed under the MIT license.
  190.         */
  191.         (function($) {
  192.         $.fn.bcSwipe = function(settings) {
  193.             var config = { threshold: 50 };
  194.             if (settings) {
  195.             $.extend(config, settings);
  196.             }
  197.             this.each(function() {
  198.             var stillMoving = false;
  199.             var start;
  200.             if ('ontouchstart' in document.documentElement) {
  201.                 this.addEventListener('touchstart', onTouchStart, false);
  202.             }
  203.             function onTouchStart(e) {
  204.                 if (e.touches.length == 1) {
  205.                 start = e.touches[0].pageX;
  206.                 stillMoving = true;
  207.                 this.addEventListener('touchmove', onTouchMove, false);
  208.                 }
  209.             }
  210.             function onTouchMove(e) {
  211.                 if (stillMoving) {
  212.                 var x = e.touches[0].pageX;
  213.                 var difference = start - x;
  214.                 if (Math.abs(difference) >= config.threshold) {
  215.                     cancelTouch();
  216.                     if(isCarouselEmpty($(this))) return;
  217.                     if (difference > 0) {
  218.                     $(this).carousel('next');
  219.                     }
  220.                     else {
  221.                     $(this).carousel('prev');
  222.                     }
  223.                 }
  224.                 }
  225.             }
  226.             
  227.             function isCarouselEmpty(carousel){
  228.             return carousel.find(".item.active").length < 1
  229.             }
  230.             function cancelTouch() {
  231.                 this.removeEventListener('touchmove', onTouchMove);
  232.                 start = null;
  233.                 stillMoving = false;
  234.             }
  235.             });
  236.             return this;
  237.         };
  238.         })(jQuery);
  239.     </script>
  240. {% endblock %}