【问题标题】:Magento 2 getChildHtmlMagento 2 getChildHtml
【发布时间】:2015-12-30 09:39:15
【问题描述】:

试图将 custom.phtml 文件包含在标题中。搜索了很多指令,但没有看到像getChildHtml这样的指令 对于 .xml 我找到了

<block class="Magento\Framework\View\Element\Template" name="test_file" template="Magento_Theme::html/header/custom.phtml"/>

对于我找到的 .phtml

<?php include ($block->getTemplateFile('Magento_Theme::html/header/custom.phtml')) ?>

这意味着,对于添加 .phtml 文件,我们可以使用 .xml 或 .phtml,但不像我们习惯的那样:将模板添加到 .xml,然后从 .phtml (getChildHtml) 调用此文件

【问题讨论】:

    标签: magento magento2 magento-2.0


    【解决方案1】:

    请尝试:

    <referenceContainer name="header.container">
    <block class="Magento\Framework\View\Element\Template" name="test_file" template="Magento_Theme::html/header/custom.phtml"/>
    </referenceContainer>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-29
      • 2014-06-23
      • 1970-01-01
      • 1970-01-01
      • 2012-06-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多