1

I'm using the luma demo for practicing.
I want to create and add a new block in my homepage like this:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="page.wrapper">
            <block name="myblock"/>
        </referenceContainer>
    </body>
</page>

It worked but I want to change this block's order before the tag "main" which class name is "page-main".

I've tried this code :

<referenceContainer name="page.wrapper" before="main"> or
<referenceContainer name="page.wrapper" before="page.main"> or
<referenceContainer name="page.wrapper" before="page-main">

None of this works. Even I put a move tag like this:

<move element="myblock" destination="page.wrapper" before="main" /> or
<move element="myblock" destination="page.wrapper" before="page.main" /> or
<move element="myblock" destination="page.wrapper" before="page-main" />

How can I put my block before that?

1 Answer 1

0

You can try with below code

<referenceContainer name="someuniquename" before="main.content">

Use some unique name.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="someuniquename" before="main.content">
            <block name="myblock"/>
        </referenceContainer>
    </body>
</page>

Make sure, you have proper block and template insted of <block name="myblock"/>. Then only you can identify wheter your block and template is at the right place.

2
  • I've found other container's name but still not work :(
    – mio
    Commented Feb 22, 2017 at 6:55
  • I finally find out what's the problem with this. It's all about the name which may just like you said.
    – mio
    Commented Mar 1, 2017 at 10:11

Your Answer

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

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