2

enter image description hereI want to display some information in account dashboard. How to override default one with new one

I want a tab similar to the one highlighted in yellow box(with custom content like User Name, Dob, etc) to be displayed between the 'Account Information' block and 'Address Block'(where the red arrow is pointing).

Ravindra
  • 147
  • 1
  • 7

1 Answers1

1

Manage from Custom module

If you want to changes the section from a custom module then

  1. create customer_account_index.xml at app/code/{Vendor}/{Module}/view/frontend/layout
  2. create a template mycustominfo.phtml at app/code/{Vendor}/{Module}/view/frontend/templates

Now, you add below code at customer_account_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="Magento\Customer\Block\Account\Dashboard\Info" 
            name="customer_account_dashboard_mycustominfo" 
            as="mycustominfo"
            before ="customer_account_dashboard_info"   
        template="{Vendor}_{Module}::mycustominfo.phtml" cacheable="false"/>
        </referenceContainer>
    </body>
</page>

Manage from Theme module

If you want to changes the section from a custom theme then

  1. create customer_account_index.xml id not exits at app/design/{VendorTheme}/{ThemeName}/Magento_Customer/layout
  2. create a template mycustominfo.phtml at app/design/{VendorTheme}/{ThemeName}/Magento_Customer/templates

Now, you add below code at customer_account_index.xml

<?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">
    <body>
        <referenceContainer name="content">
            <block class="Magento\Customer\Block\Account\Dashboard\Info" 
            name="customer_account_dashboard_mycustominfo" 
            as="mycustominfo"
            before ="customer_account_dashboard_info"   
        template="Magento_Customer::mycustominfo.phtml" cacheable="false"/>
        </referenceContainer>
    </body>
</page>
Amit Bera
  • 77,456
  • 20
  • 123
  • 237