繁体   English   中英

来自自定义模块的Magento2中的Ovewrite gallery.phtml文件

[英]Ovewrite gallery.phtml file in Magento2 from custom module

嗨,我正在构建一个模块,在该模块中,我需要从模块文件中覆盖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>

但它不是从此处渲染文件。 当我将<referenceBlock name="product.info.media.image" remove="true"/>为false时,它将开始呈现基本图像。

请提出我在做什么错。

好吧,我明白了,并在下面固定

<?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创建了一个文件,现在可以使用了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM