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.
Peter Mortensen
2151 silver badge8 bronze badges
asked Dec 28, 2017 at 8:39
-
There are no difference between original and your custom layoutRakesh Jesadiya– Rakesh Jesadiya2017年12月28日 08:41:13 +00:00Commented 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– Learner2017年12月28日 08:43:15 +00:00Commented Dec 28, 2017 at 8:43
-
when I change in vendor its working perfect.Learner– Learner2017年12月28日 08:43:51 +00:00Commented 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>Rakesh Jesadiya– Rakesh Jesadiya2017年12月28日 08:43:55 +00:00Commented Dec 28, 2017 at 8:43
-
in body tag ? @RakeshJesadiyaLearner– Learner2017年12月28日 08:46:12 +00:00Commented Dec 28, 2017 at 8:46
2 Answers 2
<?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
-
still no luck. I pasted this in override folderLearner– Learner2017年12月28日 08:57:13 +00:00Commented Dec 28, 2017 at 8:57
-
Have you clear cache?Rakesh Jesadiya– Rakesh Jesadiya2017年12月28日 08:57:50 +00:00Commented Dec 28, 2017 at 8:57
-
yes. I cleared then upgrade and then di:compileLearner– Learner2017年12月28日 08:59:21 +00:00Commented Dec 28, 2017 at 8:59
-
1please check above code is workign fineRakesh Jesadiya– Rakesh Jesadiya2017年12月28日 09:18:19 +00:00Commented Dec 28, 2017 at 9:18
-
1glad to know its help you. Its call overriding.Rakesh Jesadiya– Rakesh Jesadiya2017年12月28日 09:24:50 +00:00Commented Dec 28, 2017 at 9:24
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
-
it will decrease priority of vendor customer_account_index.xml ?Learner– Learner2017年12月28日 09:34:06 +00:00Commented 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– Lez2017年12月28日 09:41:40 +00:00Commented Dec 28, 2017 at 9:41 -
-
It's working for me...did you clear static files and cache?Lez– Lez2017年12月28日 09:48:28 +00:00Commented Dec 28, 2017 at 9:48
default