0

I am creating a custom admin theme for Magento 2 and followed the Magento 2 documentation. My problem is that all styles are removed on the backend and I do not understand why it is not defaulting to Magento/backend theme parent. Here is my theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>MyTheme</title>
<parent>Magento/backend</parent>
<media>
    <preview_image>media/preview.png</preview_image>
</media>

Here is my 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_MenuItem" setup_version="1.0.0" />
</config>

and my added di.xml to my module:

<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/MyTheme</item> <!-- Example: "Magento/backend" -->
        </argument>
    </arguments>
</type>
<!-- Admin theme. End -->
</config>

The logo works just fine but I lost all previous styling and all adminhtml looks like basic html. Any insight would be appreciated.

  • in your module.xml file, did you add sequence parameter to load Magento_Theme first? – AJ47 Feb 4 at 19:50
  • I dont believe I added this. I updated my question with my module xml files. How would I add the sequence parameter? – Joey Feb 4 at 20:00
0

Try editing your module.xml file to this:

<?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_MenuItem" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Theme"/>
        </sequence>
    </module>
</config>

As per the Magento 2 Docs you need to load Magento_Theme before your module.

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.