templates/bundles/BitBagSyliusCmsPlugin/Shop/Page/show.html.twig line 6

Open in your IDE?
  1. {% if page.fullLayout == true %}
  2.     {% set layout = '@SyliusShop/layout-full-width.html.twig' %}
  3. {% else %}
  4.     {% set layout = '@SyliusShop/layout.html.twig' %}
  5. {% endif %}
  6. {% extends layout %}
  7. {% set published = (page.publishAt is not null and page.publishAt|date("Y-m-d H:i:s") < "now"|date("Y-m-d H:i:s") or page.publishAt is null) %}
  8. {% set mainImage = null %}
  9. {% if page.image %}
  10.     {% set mainImage = page.image.path %}
  11. {% endif %}
  12. {% block banner %}
  13.     {% if
  14.         page.code != "conditions-d-utilisation"
  15.         and page.code != "conditions-generales-de-vente"
  16.         and page.code != "mentions-legales"
  17.         and page.code != "politique-de-confidentialite"
  18.         and page.template != "structure"
  19.     %}
  20.         {% if ('@SyliusShop/Banner/_banner-' ~ page.code ~ '.html.twig')|template_file_exists %}
  21.             {{ render(url('odiseo_sylius_banner_plugin_shop_partial_banner', {'template': '@SyliusShop/Banner/_banner-' ~ page.code ~ '.html.twig'})) }}
  22.         {% else %}
  23.             {{ render(url('odiseo_sylius_banner_plugin_shop_partial_banner', {'template': '@SyliusShop/Banner/_banner.html.twig'})) }}
  24.         {% endif %}
  25.     {% endif %}
  26. {% endblock %}
  27. {%- block title -%}
  28.     {% if page.title is not empty and published == true  %}
  29.         {{ page.title }}
  30.     {% else %}
  31.         {{ parent() }}
  32.     {% endif %}
  33. {%- endblock -%}
  34. {% block head %}
  35.     {{ parent() }}
  36.     {% block stylesheets %}
  37.         {{ parent() }}
  38.         {% if page.code == "contact" or page.template == "structure" %}
  39.             <script src='https://api.mapbox.com/mapbox-gl-js/v2.3.1/mapbox-gl.js'></script>
  40.             <link href='https://api.mapbox.com/mapbox-gl-js/v2.3.1/mapbox-gl.css' rel='stylesheet' />
  41.         {% endif %}
  42.         {% if page.template == "prestation" or page.template == "structure" %}
  43.             <link href='{{ asset('assets/shop/css/magnific-popup.css') }}' rel='stylesheet' />
  44.         {% endif %}
  45.     {% endblock %}
  46.     {% block metatags %}
  47.         {{ parent() }}
  48.         {% if published == true %}
  49.             {% if page.metaKeywords is not empty %}
  50.                 <meta name="keywords" content="{{ page.metaKeywords }}"/>
  51.             {% endif %}
  52.             {% if page.metaDescription is not empty %}
  53.                 <meta name="description" content="{{ page.metaDescription }}"/>
  54.             {% endif %}
  55.             <meta property="og:site_name" content="Mons Fromage" />
  56.             <meta property="og:locale" content="{{ sylius.localeCode }}" />
  57.             <meta property="og:title" content="{{ page.title|e('html_attr') }}" />
  58.             <meta property="og:url" content="{{ website_url ~ path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) }}" />
  59.             <meta property="og:type" content="website" />
  60.             <meta property="og:description" content="{{ page.metaDescription|e('html_attr') }}" />
  61.             <meta property="og:image" content="{{ website_url ~ '/' ~ mainImage }}" />
  62.             <meta name="twitter:card" content="summary" />
  63.             <meta name="twitter:title" content="{{ page.title|e('html_attr') }}" />
  64.             <meta name="twitter:description" content="{{ page.metaDescription|e('html_attr') }}" />
  65.             <meta name="twitter:image" content="{{ website_url ~ '/' ~ mainImage }}" />
  66.         {% endif %}
  67.     {% endblock %}
  68. {% endblock %}
  69. {% block content %}
  70.     {% if published == true %}
  71.         {% if page.template is not null %}
  72.             {% include 'bundles/BitBagSyliusCmsPlugin/Shop/Page/templates/_' ~ page.template ~ '.html.twig' %}
  73.         {% else %}
  74.             {% include 'bundles/BitBagSyliusCmsPlugin/Shop/Page/' ~ page.code ~ '.html.twig' %}
  75.         {% endif %}
  76.     {% else %}
  77.         {% include 'bundles/BitBagSyliusCmsPlugin/Shop/Page/Error/_notPublished.html.twig' with {'publishAt': page.publishAt} %}
  78.     {% endif %}
  79. {% endblock %}
  80. {% block javascripts %}
  81.     {{ parent() }}
  82.     {% if page.template == "prestation" or page.template == "structure" %}
  83.         <script src="{{ asset('assets/shop/js/jquery.magnific-popup.min.js') }}"></script>
  84.         <script type="text/javascript">
  85.             $(document).ready(function ($) {
  86.                 $('.{{ page.template }}-details__galerie-images').magnificPopup({
  87.                     delegate: 'a',
  88.                     fixedContentPos: false,
  89.                     midClick: true,
  90.                     gallery:{
  91.                         enabled:true
  92.                     },
  93.                     type: 'image'
  94.                 });
  95.             });
  96.         </script>
  97.     {% endif %}
  98.     {% if page.template == "structure" %}
  99.         <script type="text/javascript">
  100.             // Display the map
  101.             mapboxgl.accessToken = '{{ mapbox_key }}';
  102.             var map = new mapboxgl.Map({
  103.                 container: 'map',
  104.                 style: 'mapbox://styles/mapbox/light-v10',
  105.                 center: [{{ page.structureGpsLng }}, {{ page.structureGpsLat }}],
  106.                 zoom: 13
  107.             });
  108.             var marker = new mapboxgl.Marker({
  109.                 color: '#883412'
  110.             })
  111.                 .setLngLat([{{ page.structureGpsLng }}, {{ page.structureGpsLat }}])
  112.                 .addTo(map);
  113.             var nav = new mapboxgl.NavigationControl();
  114.             map.addControl(nav, 'top-left');
  115.         </script>
  116.     {% endif %}
  117.     {% if page.code == "contact" or page.code == "fromagers-evenementiels" or page.code == "centre-international-mons-formation" %}
  118.         <script src="https://www.google.com/recaptcha/api.js"></script>
  119.         <script type="text/javascript">
  120.             function onSubmitContactForm(token) {
  121.                 $(document).ready(function() {
  122.                     $("form#contact-form #recaptcha-token").val(token);
  123.                     var firstName = $("form#contact-form input#sylius_contact_firstname").val().trim();
  124.                     var lastName = $("form#contact-form input#sylius_contact_lastname").val().trim();
  125.                     var email = $("form#contact-form input#sylius_contact_email").val().trim();
  126.                     var phone = $("form#contact-form input#sylius_contact_phone").val().trim();
  127.                     var message = $("form#contact-form #sylius_contact_message").val().trim();
  128.                     var emailRegex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  129.                     var phoneRegex = /^(\D*\d){8,}$/;
  130.                     if((firstName === "") || (lastName === "") || (email === "") || (message === "")) {
  131.                         $("#contact-form-errors").empty().html("{{ 'sylius.contact.required_fields_are_missing'|trans }}").removeClass("hidden");
  132.                         return;
  133.                     }
  134.                     if((email !== "") && !emailRegex.test(String(email).toLowerCase())) {
  135.                         $("#contact-form-errors").empty().html("{{ 'sylius.contact.email_not_valid'|trans }}").removeClass("hidden");
  136.                         return;
  137.                     }
  138.                     if((phone !== "") && !phoneRegex.test(String(phone).toLowerCase())) {
  139.                         $("#contact-form-errors").empty().html("{{ 'sylius.contact.phone_not_valid'|trans }}").removeClass("hidden");
  140.                         return;
  141.                     }
  142.                     $("#contact-form-errors").empty().addClass("hidden");
  143.                     $("form#contact-form button").empty().html("<i class='fas fa-paper-plane'></i>{{ 'sylius.contact.sending'|trans }}");
  144.                     document.getElementById("contact-form").submit();
  145.                 });
  146.             }
  147.         </script>
  148.     {% endif %}
  149.     {% if page.code == "contact" %}
  150.         <script type="text/javascript">
  151.             mapboxgl.accessToken = '{{ mapbox_key }}';
  152.             var map = new mapboxgl.Map({
  153.                 container: 'map',
  154.                 style: 'mapbox://styles/mapbox/light-v10',
  155.                 center: [3.9129083, 46.065271],
  156.                 zoom: 13
  157.             });
  158.             var marker = new mapboxgl.Marker({
  159.                 color: '#883412'
  160.             })
  161.                 .setLngLat([3.9129083, 46.065271])
  162.                 .addTo(map);
  163.             var nav = new mapboxgl.NavigationControl();
  164.             map.addControl(nav, 'top-left');
  165.         </script>
  166.     {% endif %}
  167. {% endblock %}