custom/plugins/BettenABC/src/Resources/views/theme/page/product-detail/buttons/share.html.twig line 1

Open in your IDE?
  1. {#
  2. # Project:      www.betten-abc.de
  3. # Company:      arboro GmbH
  4. # Created by:   Daniel Geike
  5. # Created on:   01.09.22
  6. # Description:
  7. #}
  8. {% block page_product_detail_button_share %}
  9.     {# get meta title from meta title block and trim white-space #}
  10.     {% set metaTitle = block("layout_head_title_inner", "@Storefront/storefront/page/product-detail/meta.html.twig")|trim %}
  11.     {# get meta description and trim white-space #}
  12.     {% set metaDescription = page.metaInformation.metaDescription|trim|replace({
  13.         "\t": ""
  14.     }) %}
  15.     {# get page URL #}
  16.     {% set pageURL = seoUrl('frontend.detail.page', {
  17.         productId: page.product.id
  18.     }) %}
  19.     {# get media ID of first media item #}
  20.     {% set imageURL = page.product.media.first.media.url %}
  21.     {% set shareOptions = {
  22.         name: metaTitle,
  23.         description: metaDescription,
  24.         url: pageURL,
  25.         imageUrl: imageURL
  26.     } %}
  27.     <button type="button" class="btn product-detail-button product-detail-button-share" data-share="true" data-share-options="{{ shareOptions|json_encode }}">
  28.         {% sw_icon "share" %}
  29.         {{ "detail.buttons.share.label"|trans }}
  30.     </button>
  31.     {% block page_product_detail_button_share_facebook %}
  32.         {% set locale = app.request.attributes.get("_locale")|replace({
  33.             "-": "_"
  34.         }) %}
  35.         <!-- Load Facebook SDK for JavaScript -->
  36.         <div id="fb-root"></div>
  37.         <script>( function( d, s, id ) {
  38.                 var js, fjs = d.getElementsByTagName( s )[ 0 ];
  39.                 if ( d.getElementById( id ) ) return;
  40.                 js = d.createElement( s );
  41.                 js.id = id;
  42.                 js.src = 'https://connect.facebook.net/{{ locale }}/sdk.js#xfbml=1&version=v3.0';
  43.                 fjs.parentNode.insertBefore( js, fjs );
  44.             }( document, 'script', 'facebook-jssdk' ) );
  45.         </script>
  46.         <!-- Your share button code -->
  47.         <div class="fb-share-button"
  48.              data-href="{{ pageURL }}"
  49.              data-layout="button"
  50.         >
  51.         </div>
  52.     {% endblock %}
  53. {% endblock %}