Magento – How to override adminhtml phtml files in magento2

adminhtmlmagento2overrides

How to override adminhtml phtml files in magento2?

I want to place a custom text in customer edit page welcome to magento2.
For this I have created a theme and placed

app\design\adminhtml\Vendor\backend\Magento_Customer\templates\tab\view.phtml

<h1>WELCOME TO MAGENTO2</h1>
<?php echo $block->getChildHtml(); ?>

but it's not working, when I place the same in
app\code\Magento\Customer\view\adminhtml\templates\tab\view.phtml
then it's working.

Best Answer

adminhtml phtml file can be override as steps below

STEP 1: Add page layout XML in custom module.

app/code/[Vendor]/[Module]/view/adminhtml/layout/sales_order_view.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name='order_totals'>
      <action method="setTemplate">
        <argument name='template' translate="true" xsi:type='string'>[Vendor]_[Module]::order/totals.phtml</argument>
      </action>
    </referenceBlock>
</body>

STEP 2: Put template file on below path

app/code/[Vendor]/[Module]/view/adminhtml/templates/order/totals.phtml

Write custom code with existing content!!!

STEP 3: Depending on your cache settings you may need to clear your cache php bin/magento cache:clear

Hope it will work for you :)

Related Topic