5

How and what to add to be able to override any of the magento-backend module templates and what is the sequence order of the custom module or theme

2 Answers 2

11

I followed this solution https://magento.stackexchange.com/a/96559/23344 and it works like a charm.

Below its step 3 improved.

I created the module in \app\code\XXX\Backend\ and within the files:

\app\code\XXX\Backend\registration.php

<?php

 \Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE, 'XXX_Backend', __DIR__
);

\app\code\XXX\Backend\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="XXX_Backend" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Backend"/>
        </sequence>
    </module>
</config>

\app\code\XXX\Backend\etc\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">
    <type name="Magento\Theme\Model\View\Design">
        <arguments>
            <argument name="themes" xsi:type="array">
                <item name="frontend" xsi:type="string">Magento/luma</item>
                <item name="adminhtml" xsi:type="string">XXX/backend</item>
            </argument>
         </arguments>
    </type>
</config>

Finally run php bin/magento setup:upgrade

Now you could extend adminhtml template, i customize \app\design\adminhtml\XXX\backend\Magento_Sales\templates\items\column\name.phtml and it works.

6
  • I applied this solution and it works but products thumbnails is no longer visible Commented Jun 21, 2016 at 7:50
  • Which page do you mean?
    – LucScu
    Commented Jun 21, 2016 at 9:47
  • 2
    What you wrote works great in sense that it is applied, but my custom theme for admin has no generated files. I'm missing files from /pub/static after running setup:upgrade and setup:static-content:deploy. What am I missing here ? Commented Aug 6, 2016 at 8:49
  • Is your pub/static completely empty?
    – LucScu
    Commented Aug 8, 2016 at 8:09
  • was anyone able to create an adminhtml theme following the M2 docs?
    – dchayka
    Commented Aug 22, 2017 at 15:30
6

A follow-up to Luca's answer that might help others like who only look to extend the layout:

  1. in your newly created app that sets the adminhtml theme, in etc/module.xml, you have use:

    <module name="Magento_Theme"/>

as a sequence.

  1. you have to have some css file or other static content in app/design/adminhtml/name/theme/web (I placed the _theme.less file in /web/css/source). You can inspect the checkThemesInput method in Magento\Deploy\Console\Command\DeployStaticContentCommand to find out why.
3
  • 1
    +1 for your second point. I was missing this and it will not work without at least something in there. After this you need to do setup:deploy
    – tim.baker
    Commented Sep 28, 2016 at 17:57
  • For those who want to know how to override adminthml colors and CSS. magento.stackexchange.com/questions/121116/…
    – camdixon
    Commented Apr 2, 2018 at 15:38
  • I have made composer installable base admin theme for Magento 2.2.2 as I did not see any composer examples out there. This question & answer was of great help! github.com/camdixon/magento2-admin-theme
    – camdixon
    Commented Apr 2, 2018 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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