src/Flexy/FrontBundle/Themes/CoWorking/templates/pages/actualites.html.twig line 1

  1. {% extends '@Flexy/FrontBundle/Themes/CoWorking/templates/layout.html.twig' %}
  2. {% block stylesheets %}
  3. {{ parent() }}
  4.      
  5.    
  6. <style>
  7.  .pagination {
  8.     display: flex;
  9.     justify-content: center;
  10.     margin-top: 20px;
  11. }
  12. .pagination li {
  13.     margin: 0 5px;
  14.     list-style: none;
  15. }
  16. .pagination li a {
  17.     text-decoration: none;
  18.     padding: 8px 12px;
  19.     border: 1px solid #FFCB00; /* Ajout de la couleur principale */
  20.     border-radius: 5px;
  21.     color: #FFCB00; /* Texte en couleur principale */
  22.     font-weight: 600;
  23.     transition: background-color 0.3s, color 0.3s;
  24. }
  25. .pagination li a:hover {
  26.     background-color: #FFCB00; /* Couleur au survol */
  27.     color: white; /* Texte en blanc au survol */
  28. }
  29. .pagination li.active a {
  30.     background-color: #FFCB00; /* Couleur principale pour l'élément actif */
  31.     color: white; /* Texte en blanc */
  32.     border: none; /* Supprimer la bordure */
  33. }
  34. .pagination li.disabled {
  35.     display: none; /* Cacher les boutons désactivés */
  36. }
  37.     
  38.     .img-article {
  39.     width: 100%; /* La largeur de l'image s'ajuste à la colonne */
  40.     height: 260px; /* Hauteur fixe pour uniformiser toutes les images */
  41.     object-fit: cover; /* Coupe les parties excédentaires pour conserver le rapport d'aspect */
  42.     border-radius: 5px; /* Optionnel : coins arrondis */
  43. }
  44.     
  45.     #hideHeaderInPageHome{
  46.         display:none !important;
  47.     }
  48.     
  49.     .title-article{
  50.         color: #292825;
  51.         font-size: 21px;
  52.         line-height: 35px;
  53.         font-weight: 800;
  54. }
  55. .lire-suite{
  56.    
  57.     /*padding: 10px;*/
  58.     font-weight:600;
  59.     font-size:13px;
  60.     border-radius: 4px;
  61. .img-article{
  62.     width:95%;
  63. }
  64. .shadow-custom:hover{
  65.      box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
  66. }
  67.  
  68. .shadow-custom{
  69.     box-shadow: rgba(0, 0, 0, 0.02) 0px 1px 3px 0px, rgba(27, 31, 35, 0.15) 0px 0px 0px 1px;
  70. }
  71.   .custom-hr {
  72.      width: 10%;
  73.     border: 3px solid #555;
  74.     margin: 4px;
  75. }
  76. .custom-hr-1{
  77.      width: 3%;
  78.     border: 3px solid #555;
  79.     margin: 4px;
  80. }
  81.   .carousel-image {
  82.     width: 100%; /* Adapte la largeur à celle du conteneur */
  83.     height: 400px; /* Hauteur fixe pour un rendu uniforme */
  84.     object-fit: cover; /* Coupe et zoome l'image pour remplir le conteneur */
  85.     
  86. }
  87. </style>
  88.   
  89. {% endblock  %}
  90. {% block body %}
  91.  
  92. <!--Carousel-->
  93. <div id="carouselExampleInterval" class="carousel slide" data-bs-ride="carousel">
  94.   <div class="carousel-inner">
  95.    <div id="carouselExampleInterval" class="carousel slide" data-bs-ride="carousel">
  96.   <div class="carousel-inner">
  97.     {% for news in newshome %}
  98.     <div class="carousel-item {% if loop.first %}active{% endif %}" data-bs-interval="6000">
  99.       <img src="/uploads/coworking/{{ news.image }}" class="d-block w-100 carousel-image" alt="...">
  100.     </div>
  101.     {% endfor %}
  102.   </div>
  103. </div>
  104.   <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleInterval" data-bs-slide="prev">
  105.     <span class="carousel-control-prev-icon" aria-hidden="true"></span>
  106.     <span class="visually-hidden">Previous</span>
  107.   </button>
  108.   <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleInterval" data-bs-slide="next">
  109.     <span class="carousel-control-next-icon" aria-hidden="true"></span>
  110.     <span class="visually-hidden">Next</span>
  111.   </button>
  112. </div>
  113. <div class="container" style="max-width: 1230px;">
  114.  
  115.     <div class="row">
  116.         <div class="col-lg-12">
  117.             
  118.             <h1 style="font-size: 34px; color: black;" class="title-actualites mt-5 mb-2">Actualités</h1>
  119.              <hr class="custom-hr-1">
  120.             
  121.             <div class="row">
  122.                 <!-- Articles -->
  123.                 
  124.                 <div class="col-lg-9">
  125.                 
  126.          <div id="result-container">
  127.     {% include '@Flexy/FrontBundle/Themes/CoWorking/templates/pages/_sorted_results.html.twig' with { 'news': newshome } %}
  128. </div>
  129.                    {# {% for news in newshome %}
  130.     
  131.                     <article class="card shadow-custom mt-4">
  132.                         <div class="row g-0">
  133.                             <div class="col-lg-5">
  134.                                 <img class="img-article img-fluid" 
  135.                                      src="/uploads/coworking/{{ news.image }}"
  136.                                      alt="image">
  137.                             </div>
  138.                             <div class="col-lg-7 col-md-12 " >
  139.                                 <p class="mt-2" style="font-size:12px">{{ news.dateDebut|date('d M Y')|default('Aucune date') }}</p>
  140.                                 <h3>  {{ news.title }}  </h3>
  141.                                 <h2 class="title-article"> {{ news.underTitle }}</h2>
  142.                                 <p style="font-size: 15px;width:95%;">{{ news.description|slice(0, 110) ~ '...' }}</p>
  143.                                 <a href="{{path('actualite',{id:news.id})}}" class="lire-suite">Lire Plus <i style="font-size:18px" class="fa fa-play-circle" aria-hidden="true"></i></a>
  144.                                 
  145.                             </div>
  146.                         </div>
  147.                     </article>
  148.                     {% endfor %}
  149.      #}
  150.                 </div>
  151.                 <!-- Sidebar -->
  152.                 <div class="col-lg-3">
  153.                 
  154.              <select id="sortSelect" class="form-select" aria-label="Default select example">
  155.                         <option selected value="1">Les plus récentes</option>
  156.                         <option value="2">Les plus anciens</option>
  157.                 </select>
  158.                 <br>
  159.                     <!-- Remplacez 'ffff' par du contenu réel -->
  160.                     <h5 class="">Actualités récentes</h5>
  161.                     <hr class="custom-hr">
  162.                     
  163.                          {% for news in newshome %}
  164.                     {% if loop.index <= 8 %}
  165.                        <p class="mt-3" style="font-size: 14px;">{{ news.Title }}</p>
  166.                        {% endif %}
  167.                      {% endfor %}
  168.                 </div>
  169.             </div>
  170.         </div>
  171.       {% if newshome is not null %}
  172.         <div class="pagination">
  173.     {{ knp_pagination_render(newshome) }}
  174. </div>
  175.     {% endif %}
  176.  
  177.     </div>
  178.     
  179. </div>
  180.  
  181.     
  182. {% endblock %}
  183. {% block javascripts %}
  184. {{ parent() }}
  185.  
  186.  
  187. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script>
  188. <script>
  189. $(document).ready(function () {
  190.     // Fonction pour charger les actualités triées
  191.     function loadSortedNews(sortOrder, page = 1) {
  192.         console.log("Tri sélectionné :", sortOrder, "Page :", page);
  193.         $.ajax({
  194.             url: '{{ path('app_sort_data') }}',
  195.             type: 'GET',
  196.             data: { sortOrder: sortOrder, page: page },
  197.             beforeSend: function () {
  198.                 $('#result-container').html('<div class="text-center"><i class="fa fa-spinner fa-spin fa-3x"></i>  Chargement en cours ....</div>');
  199.     
  200.             },
  201.             success: function (response) {
  202.                 $('#result-container').html(response);
  203.                 // Gérer les liens de pagination après le tri
  204.                 $('#result-container').on('click', '.pagination a', function (e) {
  205.                     e.preventDefault();
  206.                     let pageUrl = $(this).attr('href');
  207.                     let pageNumber = pageUrl.split('page=')[1];
  208.                     loadSortedNews(sortOrder, pageNumber);
  209.                 });
  210.             },
  211.             error: function () {
  212.                 alert('Une erreur est survenue lors du tri.');
  213.             }
  214.         });
  215.     }
  216.     // Événement de changement sur le select
  217.     $('#sortSelect').on('change', function () {
  218.         let selectedValue = $(this).val();
  219.         loadSortedNews(selectedValue);
  220.     });
  221.     // Capture les clics de pagination dès le chargement initial
  222.     $('#result-container').on('click', '.pagination a', function (e) {
  223.         e.preventDefault();
  224.         let selectedValue = $('#sortSelect').val();
  225.         let pageUrl = $(this).attr('href');
  226.         let pageNumber = pageUrl.split('page=')[1];
  227.         loadSortedNews(selectedValue, pageNumber);
  228.     });
  229. });
  230.  
  231. </script>
  232. {% endblock %}