Does anyone know how to override the below template?
vendor\magento\module-backend\view\adminhtml\templates\media\uploader.phtml
.
[EDIT] Override block - recommended way.
Override Block:
Create a new module.
app/code/Vendor/Backend/etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Backend\Block\Media\Uploader" type="Vendor\Backend\Block\Media\Uploader" />
</config>
app/code/Vendor/Backend/Block/Media/Uploader.php
<?php
namespace Vendor\Backend\Block\Media;
class Uploader extends \Magento\Backend\Block\Media\Uploader
{
protected $_template = 'Vendor_Backend::media/uploader.phtml';
}
Create a new Admin theme:
In this case, may we need to create new Admin theme:
http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/themes/admin_theme_create.html
http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/themes/admin_theme_apply.html
Remember to specify the custom Admin theme in di.xml
.
For example:
a) Create an admin theme first:
app/design/adminhtml/Vendor/CustomTheme/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
'adminhtml/Vendor/CustomTheme',
__DIR__
);
app/design/adminhtml/Vendor/CustomTheme/theme.xml
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>My custom Admin theme</title> <!-- your theme's name -->
<parent>Magento/backend</parent> <!-- the parent theme. Example: Magento/backend -->
</theme>
b) Apply theme admin:
app/code/Vendor/Theme/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_Theme" setup_version="1.0.0">
<sequence>>
<module name="Magento_Theme"/>
</sequence>
</module>
</config>
app/code/Vendor/Theme/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Vendor_Theme',
__DIR__
);
app/code/Vendor/Theme/etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- Admin theme. Start -->
<type name="Magento\Theme\Model\View\Design">
<arguments>
<argument name="themes" xsi:type="array">
<item name="adminhtml" xsi:type="string">Vendor/CustomTheme</item>
</argument>
</arguments>
</type>
<!-- Admin theme. End -->
</config>
Magento\Backend\Block\Media\Uploader
. Set the new template.
Commented
Jul 12, 2017 at 7:26