如何在产品详细信息页面上添加facebook信使社交共享图标的url链接?
查看其他社交图标:https://magento.stackexchange.com/questions/226323/magento-2-social-share-buttons/226332
发布于 2021-12-20 02:21:44
在catalog_product_view.xml中添加此代码
<referenceContainer name="product.info.social">
<block class="Magento\Catalog\Block\Product\View" name="product.info.socialmedia" template="Magento_Catalog::product/view/socialmedia.phtml"/>
</referenceContainer>
并在以下路径创建新的phtml文件:
app/design/frontend/Custom/theme/Magento_Catalog/templates/product/view/socialmedia.phtml
在其中添加下面的代码。
<?php $_product = $block->getProduct(); ?>
<div class="social-media-icons">
<!-- Facebook -->
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode($_product->getProductUrl());?>&t=<?php echo urlencode($_product->getName())?>" onclick='javascript:window.open(this.href,"","width=640,height=480,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes");return false' title="Share on facebook">
<img src=""<?php echo $this->getViewFileUrl('Magento_Catalog::images/facebook-share.jpg'); ?>" alt="Facebook" width="12%">
</a>
</div>
https://stackoverflow.com/questions/70379288
复制相似问题