试图将 custom.phtml 文件包含在标题中。搜索了很多指令,但没有看到任何类似getChildHtml
For .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)