There are 2 solutions to remove a layout handle
from a layout file of a Magento module:
- Remove all content within the
layout handle
, including blocks, containers, the class
attribute, changing the title, etc. by using referenceBlock
, referenceContainer
, etc. in your layout XML file.
- Remove the
layout handle
directly in the layout file using the Composer patches plugin.
In case the layout handle
has many layout files (eg: the customer_account
layout handle, which has several layout files) in several modules, solution 1 is difficult to implement and maintain. Therefore, solution 2 is recommended.
For instructions on how to create a custom composer patch, refer to the topic How to create a Magento 2 Patch?
To apply a custom composer patch, I recommend using the Vaimo Composer Patches plugin.
You also can use the Cweagans Composer Patches plugin
There is a Magento official document on how to apply a custom composer patch: https://experienceleague.adobe.com/docs/commerce-operations/upgrade-guide/patches/apply.html
Regarding removing the sales_order_info_links
layout handle from the sales_order_view.xml
layout file of the Magento_Sales module. There is only one layout file, which is located in the Magento_Sales module with the following content:
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<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\Framework\View\Element\Html\Links" as="links" name="sales.order.info.links" before="-">
...
</block>
</referenceContainer>
</body>
</page>
Therefore, you can implement solution 1, which removes the layout handle content by declaring the following in your sales_order_view.xml
layout file:
<?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="sales.order.info.links" remove="true"/>
</body>
</page>
Related topic: How to change <update handle="customer_account"/> in wishlist layout