I create static block with reference name 'seller_registration_form' from Magento 2 backend which loaded in home page like this:
Now i want to insert additional content from my module, so i created cms_index_index.xml:
<?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">
<referenceBlock name="seller_registration_form">
<block class="Test\Customlayout\Block\Sellerform" name="sellerform" template="Test_Customlayout::sellerform.phtml"/>
</referenceBlock>
</page>
but the phtml file never loaded in home page, i already make sure the block file in correct place and the phtml inside view/frontend/templates folder
2 Answers 2
You didn't place your <referenceBlock> inside <body></body>. In Layout file types from official document:
Page layout declares the wireframe of a page inside the section
Also in same official document:
<body></body>is the parent of<referenceBlock>
So in your cms_index_index.xml, you should embed <referenceBlock> with <body>. So that:
<?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>
<referenceBlock name="seller_registration_form">
<block class="Test\Customlayout\Block\Sellerform" name="sellerform" template="Test_Customlayout::sellerform.phtml"/>
</referenceBlock>
</body>
</page>
-
1We need to put inside
<body></body>.Khoa Truong– Khoa Truong2017年08月21日 06:19:55 +00:00Commented Aug 21, 2017 at 6:19
I think there is some problem with you XML code
correct like this.
<?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>
<referenceContainer name="content">
<block class="Test\Customlayout\Block\Sellerform" name="sellerform" template="Test_Customlayout::sellerform.phtml"/>
</referenceContainer>
</body>
</page>
Explore related questions
See similar questions with these tags.
<body>to embed<referenceBlock>?