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.

8
  • There are no difference between original and your custom layout 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>
    – Learner
    Dec 28, 2017 at 8:43
  • when I change in vendor its working perfect.
    – Learner
    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> Dec 28, 2017 at 8:43
  • in body tag ? @RakeshJesadiya
    – Learner
    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>
8
  • still no luck. I pasted this in override folder
    – Learner
    Dec 28, 2017 at 8:57
  • Have you clear cache? Dec 28, 2017 at 8:57
  • yes. I cleared then upgrade and then di:compile
    – Learner
    Dec 28, 2017 at 8:59
  • 1
    please check above code is workign fine Dec 28, 2017 at 9:18
  • 1
    glad to know its help you. Its call overriding. 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

4
  • it will decrease priority of vendor customer_account_index.xml ?
    – Learner
    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.
    – Lez
    Dec 28, 2017 at 9:41
  • but its not working :(
    – Learner
    Dec 28, 2017 at 9:42
  • It's working for me...did you clear static files and cache?
    – Lez
    Dec 28, 2017 at 9:48

Your Answer

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

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