2

I have one module called Test_A. We can override any layout of Module-theme in Test_A by giving the same name.

Ex. Module-theme/view/frontend/layouts/frontname_controller_action.xml

can be override by creating file

Test_A/view/frontend/layouts/frontname_controller_action.xml.

But how can we override Module-theme/view/frontend/layouts/default.xml in My Module.

Why we have to create custom theme for it?

We can't modify any module's default.xml layout?

Ankita Patel
  • 592
  • 8
  • 31
26vivek
  • 457
  • 2
  • 12

1 Answers1

0

Create default.xml in your module and add this below code :

app/code/Vendor/Module/view/layout/default.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>
        <referenceBlock name="header.links">
            <!-- remove core link -->
            <referenceBlock name="my-account-link" remove="true" />
            <!-- Add new link -->
            <block class="Magento\Framework\View\Element\Html\Link" name="custom.link" before="wish-list-link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="false">Custom Link</argument>
                    <argument name="path" xsi:type="string" translate="false">custom-path</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>
Rohan Hapani
  • 17,388
  • 9
  • 54
  • 96