0

I placed a Static Block (called home_main_content) using a Widget (sort order = 0) from Magento Backend like this:

enter image description here

Now, I'm trying to insert another Static Block which I created using my custom module. I tried something like this:

<?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="columns.top">
            <block class="Vendor\Module\Block\CategoryList" template="Vendor_Module::cms.phtml" name="category_list" after="home_main_content" />
        </referenceContainer>
    </body>
</page>

but it positions itself either before all on top of the main content or on the bottom of the main content.

How can I position my category_list right after the other one home_main_content?

2
  • did you try referenceContainer name="content" ?
    – Pawan
    Jul 23 at 3:12
  • Yeah, but it didn't work. How can I sort more blocks inside the same container? I didn't understand.
    – KaMZaTa
    Jul 23 at 11:45
1

If you want your custom block "category_list" after widget then you just need to write below code in cms_index_index.xml file in your theme path app/design/frontend/PackageName/customtheme/Magento_Cms/layout

<?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="columns.top">
            <block class="Vendor\Module\Block\CategoryList" template="Vendor_Module::cms.phtml" name="category_list" after="-" />
        </referenceContainer>
    </body>
</page>

With the use of after="-" , it will show your custom block after widget element.

Cheers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.