1

I want to override following file in my custom module:

module-backend/view/adminhtml/templates/wiget/button.phtml

How can I do that?

0

You have to create a module for this.

Using plugin on class Magento\Backend\Block\Widget\Button over getTemplate method, you can achieve your requirement.

Plugin class WidgetButtonPlugin.php located at app\code\{Vendorname}\{CompanyName}\Plugin\Block.

Plugin class code look like

<?php

namespace {Vendorname}\{CompanyName}\Plugin\Block;

class WidgetButtonPlugin
{

    public function aftergetTemplate(
        \Magento\Backend\Block\Widget\Button $subject,
        $result
    ) {

        return '{Vendorname}_{CompanyName}::widget/button.phtml';
    }

}

Plugin's di.xml should be located at app\code\{Vendorname}\{CompanyName}\etc.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Backend\Block\Widget\Button">
        <plugin name="changes_button_template_file_for_widget" sortOrder="1"
                type="{Vendorname}\{CompanyName}\Plugin\Block\WidgetButtonPlugin" />
    </type>

</config>

As per as, plugin new template should be located at

app\code\{Vendorname}\{CompanyName}\view\adminhtml\templates\wiget\button.phtml

  • I try that soon, thx! – k33n Jun 19 '18 at 12:22
0

Try to add your custom admin theme

Create an Admin theme

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.