Calling multiple getChildHtml('name') only returns the first
mnjongerius opened this issue · comments
mnjongerius commented
Example:
File: Magento_Theme/layout/default.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">
<block
name="test"
class="Magento\Framework\View\Element\Template"
template="Magento_Theme::test.twig"
>
<block
name="test.block1"
class="Magento\Framework\View\Element\Template"
template="Magento_Theme::test/block1.twig"
/>
<block
name="test.block2"
class="Magento\Framework\View\Element\Template"
template="Magento_Theme::test/block2.twig"
/>
</block>
</referenceContainer>
</body>
</page>
File: Magento_Theme/templates/test.twig
<div>
{{ getChildHtml('test.block1')|raw }}
{{ getChildHtml('test.block2')|raw }}
</div>
File: Magento_Theme/templates/test/block1.twig
<h1>
Block 1
</h1>
File: Magento_Theme/templates/test/block2.twig
<h1>
Block 2
</h1>
Expected result:
<div>
<h1>
Block 1
</h1>
<h1>
Block 2
</h1>
</div>
Result:
<div>
<h1>
Block 1
</h1>
</div>
When I just use {{ getChildHtml()|raw }}
, it does return all blocks, but this isn't what I'm trying to achieve.
It also works when I only use .phtml files
Cyrill Schumacher commented
Fixed with #20