【问题标题】:How to add Block into another one - Magento 2如何将块添加到另一个 - Magento 2
【发布时间】:2019-03-01 14:41:02
【问题描述】:

怎么了!

我需要一点帮助。 我正在尝试使用以下代码创建一些块:

    <referenceContainer name="content">
    <block class="Gysa\Quotes\Block\Adminhtml\Quotes\Edit" name="quotes_quotes_edit" template="Gysa_Quotes::quote/create/form.phtml">
        <block class="Gysa\Quotes\Block\Adminhtml\Quotes\Edit\Products" template="Gysa_Quotes::quote/create/products.phtml" name="quotes_quotes_edit_products" />
    </block>
</referenceContainer>

但是“quotes_quotes_edit_products”块没有出现。我看过一些关于“Magento Sales”的例子,我可以看到这是可能的。那么我做错了什么。

任何人都可以帮忙。

干杯。

【问题讨论】:

  • 您是否在包装模板中调用了 getChildHtml?

标签: magento frontend block magento2


【解决方案1】:

这听起来可能很傻,但是您清除了缓存吗? 如果您启用模板提示,也有助于查看块是否已加载

【讨论】:

  • 我有。谢谢 这不傻。 Magento Cache 经常让我发疯。我已经做到了,但我仍然怀疑。我使用别名对其进行排序,但我很确定可以以更好的方式解决。干杯
【解决方案2】:

只需改变它:-

  <referenceContainer name="content">
    <block class="Gysa\Quotes\Block\Adminhtml\Quotes\Edit" name="quotes_quotes_edit" template="Gysa_Quotes::quote/create/form.phtml">
    name="quotes_quotes_edit_products" />
    </block>
<refernceBlock name="quotes_quotes_edit">
    <block class="Gysa\Quotes\Block\Adminhtml\Quotes\Edit\Products" template="Gysa_Quotes::quote/create/products.phtml" 
</refernceBlock>
</referenceContainer>

【讨论】:

  • 谢谢罗纳克。我会试试的
猜你喜欢
  • 2018-12-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-04
  • 1970-01-01
  • 2012-04-03
  • 2017-05-21
  • 2020-11-05
相关资源
最近更新 更多