0

How to add div main-content above in magento 2.2

enter image description here

please advance thanks for help

  • Please check my answer will help you. – Nikunj Vadariya May 7 '18 at 8:48
1
<referenceContainer name="columns.top">
    <container name="custom.view.container" htmlTag="div" htmlClass="custom-view" after="breadcrumbs">
        <block class="namespace\module\Block\entity" name="customView" template="namespace_module::custom.phtml" />
    </container>
</referenceContainer>

Flush cache and clear cache and check it.

| improve this answer | |
  • <main id="maincontent" class="page-main"></main> above – Ravindrasinh Zala May 7 '18 at 8:50
  • Please add HTML example to understand proper. – Nikunj Vadariya May 7 '18 at 8:54
1

I have tried this, below code is working for me.

<referenceContainer name="page.wrapper">
        <container name="page.wrapper.second" as="page_wrapper_second" htmlTag="div" htmlClass="page-wrapper-second" before="main.content">
               <block class="Magento\Cms\Block\Block" name="custom_menu_link">
                     <arguments>
                          <argument name="block_id" xsi:type="string">custom_menu_link</argument>
                     </arguments>
               </block>
        </container>
</referenceContainer>

you have to place your block instead of "custom_menu_link" block. The container should a child block or container.

| improve this answer | |
0

Add your layout below code :

<container name="custom.div" as="custom-div" label="div Container" htmlTag="div" htmlClass="custom_div">
    <block class="Magento\Framework\View\Element\Template"  template="Magento_Theme::customview.phtml">
</container>

Make a phtml file call customview.phtml in Magento_Theme under template folder and put some html content.

Move the container as from your layout below above code:

<move element="custom.div" destination="page.wrapper" before="main.content"/>
| improve this answer | |

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.