2

I create static block with reference name 'seller_registration_form' from Magento 2 backend which loaded in home page like this:

enter image description here

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

Prince Patel
23.1k10 gold badges102 silver badges124 bronze badges
asked Aug 21, 2017 at 3:20
3
  • Is there any reasons that you didn't insert blocks directly under content? Commented Aug 21, 2017 at 3:40
  • @PYYick the main reason, if i want to disable the module, then automatically the block wont be loaded again Commented Aug 21, 2017 at 4:17
  • How about if you use <body> to embed <referenceBlock>? Commented Aug 21, 2017 at 4:42

2 Answers 2

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>
answered Aug 21, 2017 at 4:50
1
  • 1
    We need to put inside <body></body>. Commented Aug 21, 2017 at 6:19
0

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>
answered Jun 14, 2020 at 5:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.