I am trying to move
page.main.title to child block of my custom block on custom page. I have defined one block in my layout file with template assigned to it. I want to show page title in between the html of this block's template.
So I've added another block inside it and rendered it in the template using
<?= $block->getChildHtml('custom.child.block') ?>.
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <block class="Magento\Framework\View\Element\Template" name="custom.block" template="My_Module::parent_template.phtml"> <block class="Magento\Framework\View\Element\Template" name="custom.child.block" as="custom.child.block"/> </block> <move element="page.main.title" destination="custom.child.block" before="-"/> </body> </page>
<div class="demo-content"> <?= $block->getChildHtml('custom.child.block') ?> </div>
Unfortunately the page title is not getting moved to child block of custom block. However it is being moved to custom block without any issue.
Can you please help me to understand the thing I am trying to do is possible or not. Thanks in advance.