templates/mons/stores/home.html.twig line 1

Open in your IDE?
  1. <div class="store-list__items">
  2.     {% for store in stores %}
  3.         <div class="store-list__item">
  4.             <a href="{{ path('app_shop_store_show', {code: store.code}) }}" title="{{ store.nameWhenLinked|e('html_attr') }}"><h2 class="store-list__item-title {% if store.isReseller %}reseller{% endif %}"><span class="store-list__badge {% if store.isReseller %}reseller{% endif %}">{{ loop.index }}</span>{{ store.name }}</h2></a>
  5.             <div class="store-list__infos-section">
  6.                 {% if store.address != "" and store.address is not null %}
  7.                     <div class="store-list__icon-block">
  8.                         <i class="fas fa-map-marker-alt"></i>
  9.                         <div>{{ store.address }}</div>
  10.                     </div>
  11.                 {% endif %}
  12.                 {% if store.email != "" and store.email is not null %}
  13.                     <div class="store-list__icon-block">
  14.                         <i class="fas fa-envelope"></i>
  15.                         <div><a href="mailto:{{ store.email }}" title="{{ 'sylius.stores.write_to_the_store'|trans|e('html_attr') }}">{{ store.email }}</a></div>
  16.                     </div>
  17.                 {% endif %}
  18.                 {% if store.phone != "" and store.phone is not null %}
  19.                     <div class="store-list__icon-block">
  20.                         <i class="fas fa-phone"></i>
  21.                         <div>{{ 'sylius.stores.phone'|trans }} <a href="tel:{{ store.phone }}" target="_blank" title="{{ 'sylius.stores.call_the_store'|trans|e('html_attr') }}">{{ store.phone }}</a></div>
  22.                     </div>
  23.                 {% endif %}
  24.                 {% if store.fax != "" and store.fax is not null %}
  25.                     <div class="store-list__icon-block">
  26.                         <i class="fas fa-fax"></i>
  27.                         <div>{{ 'sylius.stores.fax'|trans }} {{ store.fax }}</div>
  28.                     </div>
  29.                 {% endif %}
  30.                 {% if store.openingTimes != "" and store.openingTimes is not null %}
  31.                     <div class="store-list__icon-block store-list__icon-block--opening">
  32.                         <i class="fas fa-clock"></i>
  33.                         <div>
  34.                             <strong>{{ 'sylius.stores.opening_times'|trans }}</strong>
  35.                             <br>
  36.                             {{ store.openingTimes|raw }}
  37.                         </div>
  38.                     </div>
  39.                 {% endif %}
  40.             </div>
  41.         </div>
  42.     {% endfor %}
  43. </div>
  44. <script src='https://api.mapbox.com/mapbox-gl-js/v2.3.1/mapbox-gl.js'></script>
  45. <script type="text/javascript">
  46.     // Display the map
  47.     mapboxgl.accessToken = '{{ mapbox_key }}';
  48.     var map = new mapboxgl.Map({
  49.         container: 'map',
  50.         style: 'mapbox://styles/mapbox/light-v10',
  51.         center: [10, 47.8],
  52.         zoom: 3
  53.     });
  54.     var geojson = {
  55.         'type': 'FeatureCollection',
  56.         'features': [
  57.             {% for store in stores %}
  58.             {% if loop.index0 > 0 %}
  59.             ,
  60.             {% endif %}
  61.             {
  62.                 'type': 'Feature',
  63.                 'geometry': {
  64.                     'type': 'Point',
  65.                     'coordinates': [{% if store.gpsLng != "" and store.gpsLng is not null %}{{ store.gpsLng }}{% else %}0{% endif %}, {% if store.gpsLat != "" and store.gpsLat is not null %}{{ store.gpsLat }}{% else %}0{% endif %}]
  66.                 },
  67.                 'properties': {
  68.                     'reseller': {% if store.isReseller %}true{% else %}false{% endif %},
  69.                     'title': '{{ store.name|e('js') }}',
  70.                     'description': `
  71.                                         <div class="store-list__infos-section">
  72.                                             <div class="store-list__icon-block">
  73.                                                 <i class="fas fa-map-marker-alt"></i>
  74.                                                 <div>{{ store.address }}</div>
  75.                                             </div>
  76.                                             {% if store.email != "" and store.email is not null %}
  77.                                                 <div class="store-list__icon-block">
  78.                                                     <i class="fas fa-envelope"></i>
  79.                                                     <div><a href="mailto:{{ store.email }}" target="_blank" title="{{ 'sylius.stores.write_to_the_store'|trans|e('html_attr') }}">{{ store.email }}</a></div>
  80.                                                 </div>
  81.                                             {% endif %}
  82.                                             {% if store.phone != "" and store.phone is not null %}
  83.                                                 <div class="store-list__icon-block">
  84.                                                     <i class="fas fa-phone"></i>
  85.                                                     <div>{{ 'sylius.stores.phone'|trans|e('html_attr') }} <a href="tel:{{ store.phone }}" target="_blank" title="{{ 'sylius.stores.call_the_store'|trans|e('html_attr') }}">{{ store.phone }}</div>
  86.                                                 </div>
  87.                                             {% endif %}
  88.                                             {% if store.fax != "" and store.fax is not null %}
  89.                                                 <div class="store-list__icon-block">
  90.                                                     <i class="fas fa-fax"></i>
  91.                                                     <div>{{ 'sylius.stores.fax'|trans|e('html_attr') }} {{ store.fax }}</div>
  92.                                                 </div>
  93.                                             {% endif %}
  94.                                         </div>
  95.                                     `
  96.                 }
  97.             }
  98.             {% endfor %}
  99.         ]
  100.     };
  101.     // add markers to map
  102.     geojson.features.forEach(function (marker) {
  103.         // create a HTML element for each feature
  104.         var el = document.createElement('div');
  105.         el.className = marker.properties.reseller ? 'marker reseller' : 'marker';
  106.         // make a marker for each feature and add it to the map
  107.         new mapboxgl.Marker(el)
  108.             .setLngLat(marker.geometry.coordinates)
  109.             .setPopup(
  110.                 new mapboxgl.Popup({ offset: 25 }) // add popups
  111.                     .setHTML(
  112.                         '<h3>' +
  113.                         marker.properties.title +
  114.                         '</h3><p>' +
  115.                         marker.properties.description +
  116.                         '</p>'
  117.                     )
  118.             )
  119.             .addTo(map);
  120.     });
  121.     var nav = new mapboxgl.NavigationControl();
  122.     map.addControl(nav, 'top-left');
  123. </script>