3

I want to override the layout of magento-customer in my theme.

The vendor path is

/vendor/magento/module-customer/view/frontend/layout/customer_account_index.xml

And its code is

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 <update handle="customer_account"/>
 <body>
 <referenceBlock name="page.main.title">
 <action method="setPageTitle">
 <argument translate="true" name="title" xsi:type="string">My Dashboard</argument>
 </action>
 </referenceBlock>
 <referenceContainer name="content">
 <block class="Magento\Framework\View\Element\Template" name="customer_account_dashboard_top" as="top"/>
 <block class="Magento\Customer\Block\Account\Dashboard\Info" name="customer_account_dashboard_info" as="info" template="account/dashboard/info.phtml" cacheable="false"/>
 <block class="Magento\Customer\Block\Account\Dashboard\Address" name="customer_account_dashboard_address" as="address" template="account/dashboard/address.phtml" cacheable="false"/>
 </referenceContainer>
 </body>
</page>

Now I am trying to override in my theme,

app/design/frontend/Oneclout/jblashes/Magento_Customer/layout/customer_account_index.xml

and the code is

 <?xml version="1.0"?>
 <!--
 /**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
 -->
 <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 <update handle="customer_account"/>
 <body>
 <referenceBlock name="page.main.title">
 <action method="setPageTitle">
 <argument translate="true" name="title" xsi:type="string">My Dashboard</argument>
 </action>
 </referenceBlock>
 <referenceContainer name="content">
 <block class="Magento\Customer\Block\Account\Dashboard\Info" name="customer_account_dashboard_info" as="info" template="account/dashboard/info.phtml" cacheable="false"/>
 <block class="Magento\Customer\Block\Account\Dashboard\Address" name="customer_account_dashboard_address" as="address" template="account/dashboard/address.phtml" cacheable="false"/>
 </referenceContainer>
<block class="Magento\Framework\View\Element\Template" name="customer_account_dashboard_top" as="top"/>
 </body>
 </page>

I just want to override this.

asked Dec 28, 2017 at 8:39
8
  • There are no difference between original and your custom layout Commented Dec 28, 2017 at 8:41
  • @RakeshJesadiya I moved this block on last <block class="Magento\Framework\View\Element\Template" name="customer_account_dashboard_top" as="top"/> </body> Commented Dec 28, 2017 at 8:43
  • when I change in vendor its working perfect. Commented Dec 28, 2017 at 8:43
  • use <referenceContainer name="content"> <block class="Magento\Customer\Block\Account\Dashboard\Info" name="customer_account_dashboard_info" as="info" template="account/dashboard/info.phtml" cacheable="false"/> <block class="Magento\Customer\Block\Account\Dashboard\Address" name="customer_account_dashboard_address" as="address" template="account/dashboard/address.phtml" cacheable="false"/> <block class="Magento\Framework\View\Element\Template" name="customer_account_dashboard_top" as="top"/> </referenceContainer> Commented Dec 28, 2017 at 8:43
  • in body tag ? @RakeshJesadiya Commented Dec 28, 2017 at 8:46

2 Answers 2

4
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 <update handle="customer_account"/>
 <body>
 <move element="customer_account_dashboard_top" destination="content" after="customer_account_dashboard_address" />
 </body>
</page>
answered Dec 28, 2017 at 8:52
8
  • still no luck. I pasted this in override folder Commented Dec 28, 2017 at 8:57
  • Have you clear cache? Commented Dec 28, 2017 at 8:57
  • yes. I cleared then upgrade and then di:compile Commented Dec 28, 2017 at 8:59
  • 1
    please check above code is workign fine Commented Dec 28, 2017 at 9:18
  • 1
    glad to know its help you. Its call overriding. Commented Dec 28, 2017 at 9:24
1

Add this:

<move element="customer_account_dashboard_top" destination="content" after="customer_account_dashboard_address">

inside the <body> tag of:

app/design/frontend/Oneclout/jblashes/Oneclout_jblashes/layout/default.xml

it should work also in:

app/design/frontend/Oneclout/jblashes/Magento_Customer/layout/customer_account_index.xml

answered Dec 28, 2017 at 9:21
4
  • it will decrease priority of vendor customer_account_index.xml ? Commented Dec 28, 2017 at 9:34
  • @Learner It won't overwrite the vendor customer_account_index.xml, it will just move the element where you want it to go. And it is good practice to have all your custom <move> elements in your themes default.xml (app/design/frontend/Oneclout/jblashes/Oneclout_jblashes/layout/default.xml) so you have them all in one place for future situations. Commented Dec 28, 2017 at 9:41
  • but its not working :( Commented Dec 28, 2017 at 9:42
  • It's working for me...did you clear static files and cache? Commented Dec 28, 2017 at 9:48

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.