custom/plugins/TcinnThemeWareClean/src/Resources/views/storefront/themeware/product-detail/twt-product-videos.html.twig line 1

Open in your IDE?
  1. {# ThemeWare "Product videos" on product pages via custom fileds #}
  2. {#
  3.     Create container and add product videos
  4.     @Storefront/storefront/themeware/product-detail/twt-product-videos.html.twig
  5. #}
  6. {# ---------------- START: SET TEMPLATE VARS ---------------- #}
  7. {# ThemeWare: Set theme variables #}
  8. {% set twtProductDetailProductVideosAdvancedPrivacy = theme_config('twt-product-detail-product-videos-advanced-privacy') %}
  9. {% set twtProductDetailProductVideosNeedConfirmation = theme_config('twt-product-detail-product-videos-need-confirmation') %}
  10. {% set twtProductDetailProductVideosPlaceholderLayoutType = theme_config('twt-product-detail-product-videos-placeholder-layout-type') %}
  11. {% set twtProductDetailProductVideosPlaceholderPreviewImage = theme_config('twt-product-detail-product-videos-placeholder-preview-image') %}
  12. {% set twtProductDetailProductVideosShowControls = theme_config('twt-product-detail-product-videos-show-controls') %}
  13. {# ---------------- END: SET TEMPLATE VARS ---------------- #}
  14. {# @TODO
  15.     Konfiguration:
  16.     - Button (Color, Outline)
  17.     - Backdrop (Color, ..)
  18.     - Placeholder (Color, ..)
  19.     - Apply styling to Shopware video CMS elements
  20.     - ..
  21. #}
  22. {# ThemeWare: Add product videos #}
  23. {% block twt_product_detail_videos %}
  24.     <div class="twt-product-detail-videos twt-videos">
  25.         {% block twt_product_detail_videos_inner %}
  26.             {# ThemeWare: Add title (only in tab "Description") #}
  27.             {% block twt_product_detail_videos_title %}
  28.                 {% if position == "description" %}
  29.                     {% if twtCustomFields.product.twt_clean_pro_custom_field__product__youtube_video is not empty or twtCustomFields.product.twt_clean_pro_custom_field__product__vimeo_video is not empty %}
  30.                         <div class="h5 twt-product-detail-product-videos-title">
  31.                             {{ 'twt.detail.customFields.productVideos.title'|trans }}
  32.                         </div>
  33.                     {% endif %}
  34.                 {% endif %}
  35.             {% endblock %}
  36.             {# ThemeWare: YouTube-Video(s) #}
  37.             {# TODO: Add configuration (Steuerelemente, Erweiterter Datenschutz, ...) #}
  38.             {# <iframe width="560" height="315" src="https://www.youtube.com/embed/aVw60mnS21o?controls=0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> #}
  39.             {# https://github.com/shopware/platform/blob/d6c853ca3b6b167d61d70e6329f4fcface5c5245/src/Storefront/Resources/views/storefront/element/cms-element-youtube-video.html.twig #}
  40.             {% block twt_product_detail_videos_youtube %}
  41.                 {% if twtCustomFields.product.twt_clean_pro_custom_field__product__youtube_video is not empty %}
  42.                     {% set youtubeIDs = twtCustomFields.product.twt_clean_pro_custom_field__product__youtube_video|split(',') %}
  43.                     <div class="twt-product-detail-product-videos-container">
  44.                         {% for youtubeID in youtubeIDs %}
  45.                             {% set videoId = youtubeID|trim %}
  46.                             {# Advanced privacy mode #}
  47.                             {% if twtProductDetailProductVideosAdvancedPrivacy == 2 %}
  48.                                 {% set videoUrl = 'https://www.youtube-nocookie.com/embed/' %}
  49.                             {% else %}
  50.                                 {% set videoUrl = 'https://www.youtube.com/embed/' %}
  51.                             {% endif %}
  52.                             {% set videoUrl = videoUrl ~ videoId ~ '?' ~ 'rel=0' ~ '&'  %}
  53.                             {# Show video controls #}
  54.                             {% if twtProductDetailProductVideosShowControls == 1 %}
  55.                                 {% set videoUrl = videoUrl ~ 'controls=0' ~ '&' %}
  56.                             {% endif %}
  57.                             {% set videoUrl = videoUrl ~ 'disablekb=1' %}
  58.                             {% set iframeClass = 'embed-responsive-item' %}
  59.                             {% block twt_product_detail_videos_youtube_embed %}
  60.                                 <div class="twt-product-video is-youtube embed-responsive embed-responsive-16by9" itemprop="video"> {# 16:9 aspect ratio #}
  61.                                     <div class="responsive-video">
  62.                                         {% block twt_product_detail_videos_youtube_embed_inner %}
  63.                                             {% if twtProductDetailProductVideosNeedConfirmation == 1 %}
  64.                                                 <iframe class="{{ iframeClass }}"
  65.                                                         src="{{ videoUrl }}"
  66.                                                         frameborder="0"
  67.                                                         allowfullscreen>
  68.                                                 </iframe>
  69.                                             {% else %}
  70.                                                 {% set pluginConfiguration = {
  71.                                                     videoUrl: videoUrl,
  72.                                                     iframeClasses: [ iframeClass ],
  73.                                                     btnClasses: [ 'btn', 'btn-outline-secondary' ],
  74.                                                     backdropClasses: [ 'twt-product-video__backdrop' ],
  75.                                                     confirmButtonText: 'component.cms.vimeo.acceptButtonLabel'|trans,
  76.                                                     overlayText: 'component.cms.vimeo.privacyNotice'|trans({
  77.                                                         '%url%': path('frontend.cms.page',{ id: config('core.basicInformation.privacyPage') }),
  78.                                                         '%platform%': 'YouTube'
  79.                                                     })|raw
  80.                                                 } %}
  81.                                                 {% block twt_product_detail_videos_youtube_embed_placeholder %}
  82.                                                     <div class="twt-product-video__placeholder"
  83.                                                          data-cms-gdpr-video-element="true"
  84.                                                          data-cms-gdpr-video-element-options="{{ pluginConfiguration|json_encode }}">
  85.                                                         {# Preview layouts #}
  86.                                                         {% if twtProductDetailProductVideosPlaceholderLayoutType == 3 %}
  87.                                                             {# Custom image #}
  88.                                                             <img class="product-detail-youtube-video-placeholder-img" src="{{ twtProductDetailProductVideosPlaceholderPreviewImage|sw_encode_url }}">
  89.                                                         {% elseif twtProductDetailProductVideosPlaceholderLayoutType == 2 %}
  90.                                                             {# Icon #}
  91.                                                             {% sw_include '@Storefront/storefront/themeware/twt-social-icons.html.twig' ignore missing with {
  92.                                                                 icon: 'youtube',
  93.                                                                 style: 'isolated'
  94.                                                             } %} {# Uses ThemeWare's social icons #}
  95.                                                         {% endif %}
  96.                                                         {# Youtube thumbnail #}
  97.                                                         {#
  98.                                                         <img class="product-detail-youtube-video-placeholder-img" src="http://img.youtube.com/vi/{{ videoId }}/maxresdefault.jpg">
  99.                                                         #}
  100.                                                     </div>
  101.                                                 {% endblock %}
  102.                                             {% endif %}
  103.                                         {% endblock %}
  104.                                     </div>
  105.                                 </div>
  106.                             {% endblock %}
  107.                         {% endfor %}
  108.                     </div>
  109.                 {% endif %}
  110.             {% endblock %}
  111.             {# ThemeWare: Vimeo-Video(s) #}
  112.             {# <div style="padding:56.25% 0 0 0;position:relative;"><iframe src="https://player.vimeo.com/video/213807531?color=ffffff&byline=0&portrait=0" style="position:absolute;top:0;left:0;width:100%;height:100%;" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe></div><script src="https://player.vimeo.com/api/player.js"></script> #}
  113.             {# https://github.com/shopware/platform/blob/d6c853ca3b6b167d61d70e6329f4fcface5c5245/src/Storefront/Resources/views/storefront/element/cms-element-vimeo-video.html.twig #}
  114.             {% block twt_product_detail_videos_vimeo %}
  115.                 {% if twtCustomFields.product.twt_clean_pro_custom_field__product__vimeo_video is not empty %}
  116.                     {% set vimeoIDs = twtCustomFields.product.twt_clean_pro_custom_field__product__vimeo_video|split(',') %}
  117.                     <div class="twt-product-detail-product-videos-container">
  118.                         {% for vimeoID in vimeoIDs %}
  119.                             {% set videoId = vimeoID|trim %}
  120.                             {% set videoUrl = 'https://player.vimeo.com/video/' %}
  121.                             {% set videoUrl = videoUrl ~ videoId ~ '?'  %}
  122.                             {# Show video controls #}
  123.                             {% if twtProductDetailProductVideosShowControls == 1 %}
  124.                                 {% set videoUrl = videoUrl ~ 'controls=false' ~ '&' %}
  125.                             {% endif %}
  126.                             {% set iframeClass = 'embed-responsive-item' %}
  127.                             {% block twt_product_detail_videos_vimeo_embed %}
  128.                                 <div class="twt-product-video is-vimeo embed-responsive embed-responsive-16by9" itemprop="video"> {# 16:9 aspect ratio #}
  129.                                     <div class="responsive-video">
  130.                                         {% block twt_product_detail_videos_vimeo_embed_inner %}
  131.                                             {% if twtProductDetailProductVideosNeedConfirmation == 1 %}
  132.                                                 <iframe class="{{ iframeClass }}"
  133.                                                         src="{{ videoUrl }}"
  134.                                                         style="position:absolute;top:0;left:0;width:100%;height:100%;"
  135.                                                         frameborder="0"
  136.                                                         allow="autoplay; fullscreen; picture-in-picture"
  137.                                                         allowfullscreen>
  138.                                                 </iframe>
  139.                                                 {#<script src="https://player.vimeo.com/api/player.js"></script>#}
  140.                                             {% else %}
  141.                                                 {% set pluginConfiguration = {
  142.                                                     videoUrl: videoUrl,
  143.                                                     iframeClasses: [ iframeClass ],
  144.                                                     btnClasses: [ 'btn', 'btn-outline-secondary' ],
  145.                                                     backdropClasses: [ 'twt-product-video__backdrop' ],
  146.                                                     confirmButtonText: 'component.cms.vimeo.acceptButtonLabel'|trans,
  147.                                                     overlayText: 'component.cms.vimeo.privacyNotice'|trans({
  148.                                                         '%url%': path('frontend.cms.page',{ id: config('core.basicInformation.privacyPage') }),
  149.                                                         '%platform%': 'Vimeo'
  150.                                                     })|raw
  151.                                                 } %}
  152.                                                 {% block twt_product_detail_videos_vimeo_embed_placeholder %}
  153.                                                     <div class="twt-product-video__placeholder"
  154.                                                          data-cms-gdpr-video-element="true"
  155.                                                          data-cms-gdpr-video-element-options="{{ pluginConfiguration|json_encode }}">
  156.                                                         {# Preview layouts #}
  157.                                                         {% if twtProductDetailProductVideosPlaceholderLayoutType == 3 %}
  158.                                                             {# Custom image #}
  159.                                                             <img class="product-detail-youtube-video-placeholder-img" src="{{ twtProductDetailProductVideosPlaceholderPreviewImage|sw_encode_url }}">
  160.                                                         {% elseif twtProductDetailProductVideosPlaceholderLayoutType == 2 %}
  161.                                                             {# Icon #}
  162.                                                             {% sw_include '@Storefront/storefront/themeware/twt-social-icons.html.twig' ignore missing with {
  163.                                                                 icon: 'vimeo',
  164.                                                                 style: 'isolated'
  165.                                                             } %} {# Uses ThemeWare's social icons #}
  166.                                                         {% endif %}
  167.                                                         {# Vimeo thumbnail #}
  168.                                                         {# Under construction... #}
  169.                                                     </div>
  170.                                                 {% endblock %}
  171.                                             {% endif %}
  172.                                         {% endblock %}
  173.                                     </div>
  174.                                 </div>
  175.                             {% endblock %}
  176.                         {% endfor %}
  177.                     </div>
  178.                 {% endif %}
  179.             {% endblock %}
  180.         {% endblock %}
  181.     </div>
  182. {% endblock %}