cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.12 content for custom module in customer account shows up as parent to div.sidebar-main

SOLVED

Magento 2.12 content for custom module in customer account shows up as parent to div.sidebar-main

I have a custom module with several content pages, that link to each other and should show up in customer account. The first one works fine, I have a link in the menu to it and it shows up next to the menu as it should. The other pages show up above the menu, pushing the menu to the bottom. The layout files are the same. The only difference is, that they don't have a link in the customer account menu.

So, for the one that works, the div shows up before the div.sidebar-menu, as a sibling to it - and that displays correctly.

The other content shows up in a div that is a parent to div.sidebar-menu and the content shows up above the menu. Does anyone know, how I can fix this?

 

Here is the layout for the one that works:

<?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" layout="2columns-left">
    <update handle="customer_account"/>
       <body>
         <referenceBlock name="page.main.title">
           <action method="setPageTitle">
              <argument translate="true" name="title" xsi:type="string">My Index Page</argument>
           </action>
        </referenceBlock>
        <referenceContainer name="page.messages">
              <block class="Magento\Framework\View\Element\Messages" name="messages" as="messages"/>
          </referenceContainer>
          <referenceContainer name="content">
              <block type="core/template" class="[Vendor]\[ModuleName]\Block\ShowAll" name="modulename_index_index.view" before="div.sidebar-main" template="Vendor_ModuleName::index.phtml" cacheable="false" />
          </referenceContainer>
      </body>
  </page>

Here is the layout for the one that doesn't work:

<?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" layout="2columns-left">
    <update handle="customer_account"/>
       <body>
         <referenceBlock name="page.main.title">
           <action method="setPageTitle">
              <argument translate="true" name="title" xsi:type="string">Add New Page</argument>
           </action>
        </referenceBlock>
        <referenceContainer name="page.messages">
              <block class="Magento\Framework\View\Element\Messages" name="messages" as="messages"/>
          </referenceContainer>
          <referenceContainer name="content">
              <block type="core/template" class="[Vendor]\[ModuleName]\Block\AddNew" name="modulename_index_index.view" before="div.sidebar-main" template="Vendor_ModuleName::new.phtml" cacheable="false" />
          </referenceContainer>
      </body>
  </page>
4 REPLIES

Re: Magento 2.12 content for custom module in customer account shows up as parent to div.sidebar-mai

You have to replace modulename_index_index.view with your custom new name in your block.

If two block with same name exist then its override and not working as expected.
Also type="core/template" is not support in magento 2 so its ignore.

<?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" layout="2columns-left">
    <update handle="customer_account"/>
       <body>
         <referenceBlock name="page.main.title">
           <action method="setPageTitle">
              <argument translate="true" name="title" xsi:type="string">Add New Page</argument>
           </action>
        </referenceBlock>
        <referenceContainer name="page.messages">
              <block class="Magento\Framework\View\Element\Messages" name="messages" as="messages"/>
          </referenceContainer>
          <referenceContainer name="content">
              <block class="[Vendor]\[ModuleName]\Block\AddNew" name="modulename_index_index.new" before="div.sidebar-main" template="Vendor_ModuleName::new.phtml" cacheable="false" />
          </referenceContainer>
      </body>
  </page>

Clear cache and check again.

 

if issue solved, click Kudos/Accept as solutions.

If Issue Solved, Click Kudos/Accept As solutions.

Re: Magento 2.12 content for custom module in customer account shows up as parent to div.sidebar-mai

Sorry, they both have different names. One is [modulename]_index_index, the other is [modulename]_index_add.

Re: Magento 2.12 content for custom module in customer account shows up as parent to div.sidebar-mai

Please show your final xml file code? which code contains xml for both handle?

Thanks.

If Issue Solved, Click Kudos/Accept As solutions.

Re: Magento 2.12 content for custom module in customer account shows up as parent to div.sidebar-mai

I found my problem.

I had an open div in the content.