templates/front/hotel/detail/_header.html.twig line 1

Open in your IDE?
  1. {# En-tête pleine largeur : fil d'Ariane, nom + étoiles, adresse, partage, TripAdvisor #}
  2. <nav class="hd-crumb" aria-label="breadcrumb">
  3.     <a href="{{ path('app_main') }}">{{ 'Pages.HotelDetail.Home'|trans({}, 'messages_front') }}</a>
  4.     {% if hotel_data.country is not empty %}<span aria-hidden="true">›</span><span>{{ hotel_data.country }}</span>{% endif %}
  5.     {% if hotel_data.city is not empty %}<span aria-hidden="true">›</span><span>{{ hotel_data.city }}</span>{% endif %}
  6.     <span aria-hidden="true">›</span><span aria-current="page">{{ hotel_data.name }}</span>
  7. </nav>
  8. <header class="hd-top">
  9.     <div class="hd-top-main">
  10.         <h1 class="hd-title">
  11.             {{ hotel_data.name }}
  12.             {# Note 1 à 7 (les sources HUB peuvent renvoyer « 4* ») ; 0 ou vide → pas d'étoiles #}
  13.             {% set stars = hotel_data.starRating|default('')|replace({'*': ''})|trim %}
  14.             {% if stars matches '/^[1-7]$/' %}
  15.                 <span class="hd-stars" aria-label="{{ stars }} {{ 'Pages.HotelOfferDetail.Messages.Stars'|trans({}, 'messages_front') }}">
  16.                     {% for i in 1..stars %}<i class="fas fa-star" aria-hidden="true"></i>{% endfor %}
  17.                 </span>
  18.             {% endif %}
  19.         </h1>
  20.         <div class="hd-loc">
  21.             {% if hotel_address is not empty %}
  22.                 <span><i class="fas fa-map-marker-alt" aria-hidden="true"></i>{{ hotel_address }}</span>
  23.             {% endif %}
  24.             <a href="#hotel-location"><i class="bi bi-map" aria-hidden="true"></i>{{ 'Pages.HotelDetail.SeeOnMap'|trans({}, 'messages_front') }}</a>
  25.             {% if hotel_data.tripadvisorId is defined and hotel_data.tripadvisorId %}
  26.                 <span class="hd-tripadvisor" id="tripInfos"></span>
  27.             {% endif %}
  28.         </div>
  29.     </div>
  30.     <div class="dropdown hd-share">
  31.         <button class="hd-btn-ghost" type="button" data-bs-toggle="dropdown" aria-expanded="false"
  32.                 aria-label="{{ 'Pages.HotelOfferDetail.Messages.Share'|trans({}, 'messages_front') }}">
  33.             <i class="bi bi-share" aria-hidden="true"></i>
  34.             <span class="hd-share-label">{{ 'Pages.HotelDetail.Share'|trans({}, 'messages_front') }}</span>
  35.         </button>
  36.         <div class="dropdown-menu dropdown-menu-end hd-share-menu">
  37.             {{ include('front/social-media/index.html.twig') }}
  38.         </div>
  39.     </div>
  40. </header>
  41. {% if hotel_data.tripadvisorId is defined and hotel_data.tripadvisorId %}
  42.     {# Note TripAdvisor : appel conservé tel quel, seul l'emplacement d'affichage change #}
  43.     <script>
  44.         $(document).ready(function () {
  45.             function publishTripadvisor(data) {
  46.                 var htmlview = '<img alt="' + data.rating + ' étoiles" src="' + data.rating_image_url + '"/> ' +
  47.                     '<a href="' + data.web_url + '" target="_blank" rel="noopener">' + data.num_reviews + ' Reviews on TripAdvisor</a>';
  48.                 $("#tripInfos").html(htmlview);
  49.             }
  50.             $.ajax({
  51.                 url: 'https://api.tripadvisor.com/api/partner/2.0/location/{{ hotel_data.tripadvisorId }}?key=c1603974aae14de9b91f3156bc107e6c',
  52.                 type: "POST",
  53.                 dataType: "json",
  54.                 success: publishTripadvisor,
  55.                 error: function (xhr) {
  56.                     console.log("TripAdvisor error " + xhr.status);
  57.                 },
  58.             });
  59.         });
  60.     </script>
  61. {% endif %}