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?

Khoa Truong
32.5k11 gold badges91 silver badges159 bronze badges
asked Feb 18, 2017 at 7:48

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.

answered Feb 20, 2017 at 7:45
2
  • I've found other container's name but still not work :( 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. Commented Mar 1, 2017 at 10:11

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.