Thank you @Alex! Your solution worked for me! I can see from the source that admin area is using my theme now.
Steps:
- create a new theme in
app/design/adminhtml/Vendor/Themename
. In that directory, create a theme.xml
:
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>My Theme Tile</title>
<parent>Magento/backend</parent>
</theme>
And a registration.php:
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
'adminhtml/Vendor/Themename',
__DIR__
);
- Either create new module for deploying your theme, or use some existing module; either way, in your modules
module.xml
add the sequence
xml element to make sure your theme gets loaded last.
<config>
<module name="My_Custommodule" setup_version="2.0.0">
<sequence>
<module name="Magento_Theme"/>
</sequence>
</module>
</config>
and in your custom modules etc/di.xml
add the fragment that specifies the admin theme to use:
<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="adminhtml" xsi:type="string">Vendor/Themename</item>
</argument>
</arguments>
</type>
</config>
- run
setup:upgrade
and voila! Check what theme is being used by viewing source: all css and js files should now be loaded from /pub/static/adminhtml/Vendor/Themename/[language]/....
However, all admin pages seems to be missing styles. I am in developer mode, and did a setup:static-content:deploy [languages]
(with no errors) but that did not resolve the issue. I have had this same issue on the frontend as well, but cant remember how I fixed it.. do I need to copy js and css files from magento-backend
module to make this work?
ISSUE RESOLVED: it appears I have run into this issue: Correct way to Update a Theme's Parent in Magento 2 where if I install my theme and then change the parent to something else in theme.xml
, it will no be updated in the database and it wont take effect. I had initially put Magento/blank in the parent-element, and that obviously did not work at all, and changing it to Magento/backend later did not help either (as per the link above). So I went in the database and set the parent_id for my theme by hand. And just like that, everything works :)