【问题标题】:Incorrect Magento 2 layouts override behavior不正确的 Magento 2 布局覆盖行为
【发布时间】:2019-12-16 04:38:00
【问题描述】:
  1. 安装了 clear magento 2.3.2
  2. 创建了简单的自定义主题,其中包含(theme.xmlregistration.phpCustomTheme/Magento_Customer/layout/customer_account_create.xml)。
  3. 我还创建了一个简单的扩展程序,它向客户帐户创建表单添加了一个自定义字段(此扩展程序也使用customer_account_create.xml)。
<body>
   <referenceContainer name="form.additional.info">
       <block class="CompanyName\ModuleName\Block\Test" name="test"
              template="CompanyName_ModuleName::form/test.phtml"/>
   </referenceContainer>
</body>

在那之后我得到了奇怪的行为: 如果我的CustomTheme/Magento_Customer/layout/customer_account_create.xml 就像来自核心的原始文件一样,则将非标准字段添加到表单中,而我的自定义扩展名没有问题。

但是如果我要修改我的文件CustomTheme/Magento_Customer/layout/customer_account_create.xml(例如我刚刚添加了这个字符串来删除迷你车:`)。 我的非标准字段不适用于表单

一切看起来好像我在自定义主题中修改布局以满足我的需要(从注册页面中删除一些元素),然后使用此布局或引用此布局的所有其他自定义扩展将停止工作。

【问题讨论】:

标签: magento layout magento2


【解决方案1】:

https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/layout-override.html

我认为在进行任何大的修改之前,你需要多阅读一下你自己的自定义主题的概念和开发过程,最后你会得到一个非常糟糕的结果并且不可持续的代码。

【讨论】:

    【解决方案2】:
    猜你喜欢
    • 2011-02-25
    • 2022-06-19
    • 1970-01-01
    • 1970-01-01
    • 2013-07-01
    • 2012-05-13
    • 2012-06-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多