Magento 2:模板文件没有被正确覆盖

问题描述 投票:0回答:2

我编写了以下代码来覆盖magento 2前端客户编辑表单。

customer_account_edit.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <referenceBlock name="customer_edit">
                <action method="setTemplate">
                    <argument name="template" xsi:type="string">Test_Modul::customer/form/edit.phtml</argument>
                </action>
            </referenceBlock>
        </referenceContainer>
    </body>
</page>

但它没有用。请帮我解决一下吗?

magento2
2个回答
0
投票
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <referenceBlock name="customer_edit">
                <action method="setTemplate">
                    <argument name="template" xsi:type="string">Emipro_Module::customer/form/edit.phtml</argument>
                </action>
            </referenceBlock>
        </referenceContainer>
    </body>
</page>

我使用上面的代码,它的工作对我来说很好。你的代码似乎也正确。你是否在适当的位置制作了你的phtml文件,如:Vendor / Module_Name / view / frontend / templates / customer / form / edit.phtml

还要检查模块名称或路径中是否存在任何拼写错误。


0
投票

customer_account_edit.xml

  <?xml version="1.0"?>
  <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <body>
    <referenceContainer name="content">
        <referenceBlock name="customer_edit">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Test_Module::customer/form/edit.phtml</argument>
            </action>
        </referenceBlock>
    </referenceContainer>
</body>

您需要在Path上为此创建模板文件。应用程序/代码/测试/模块/视图/前端/模板/客户/形式/ edit.phtml

© www.soinside.com 2019 - 2024. All rights reserved.