【问题标题】:Ovewrite gallery.phtml file in Magento2 from custom module从自定义模块覆盖 Magento2 中的 gallery.phtml 文件
【发布时间】:2016-04-05 11:30:20
【问题描述】:

您好,我正在构建一个模块,我需要在其中覆盖我的模块文件中的 gallery.phtml 文件。

为此,我在我们的模块布局文件夹中创建了一个catalog_product_view.xml,其中包含以下内容

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

    <body>
        <referenceBlock name="product.info.media.image" remove="true"/>
        <referenceContainer name="product.info.media">

                <block class="Magento\Catalog\Block\Product\View\Gallery" name="product.info.media.image" template="product/view/gallery.phtml"/>

        </referenceContainer>

    </body>
</page>

但它没有从这里渲染文件。当我设置 &lt;referenceBlock name="product.info.media.image" remove="true"/&gt; 为 false 它开始渲染基础图像。

请指出我做错了什么。

【问题讨论】:

    标签: xml magento templates overriding magento2


    【解决方案1】:

    好的,我得到它并固定在下面

    <?xml version="1.0"?>
    <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
    
            <referenceBlock name="product.info.media.image" remove="true"/>
    
            <referenceContainer name="product.info.media">
                    <block class="Magento\Catalog\Block\Product\View\Gallery" name="product.info.media.cusimage" template="Eecom_Productzoom::Eecom_Productzoom/gallery.phtml" />
            </referenceContainer>
        </body>
    </page>
    

    我在这里创建了一个文件 Eecom_Productzoom/gallery.phtml 现在它可以工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-11
      • 1970-01-01
      • 2016-01-16
      • 2016-04-08
      • 1970-01-01
      • 2023-04-03
      相关资源
      最近更新 更多