0

I am trying to simple change the logo shown on the admin login page. After creating the following files i have run

magento setup:upgrade
magento setup:static-content:deploy -f
magento setup:di:compile
magento cache:clean

app/design/adminhtml/Myvendor/mycustomadmintheme/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>
<parent>Magento/backend</parent>
</theme>

app/design/adminhtml/Myvendor/mycustomadmintheme/registration.php

<?php
 \Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
'adminhtml/Myvendor/mycustomadmintheme',
__DIR__
);

app/design/adminhtml/Myvendor/mycustomadmintheme/Magento_Backend/layout/default.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="logo">
            <arguments>
                <argument name="logo_file" xsi:type="string">images/mycustom_logo.png</argument>
                <argument name="logo_width" xsi:type="number">283</argument>
                <argument name="logo_height" xsi:type="number">85</argument>\
                <argument name="logo_alt" xsi:type="string">custom_logo</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

app/design/adminhtml/Myvendor/mycustomadmintheme/Magento_Backend/layout/admin_logo.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-login" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="logo">
            <arguments>
                <argument name="logo_image_src" xsi:type="string">images/mycustom_logo.png</argument>
                <argument name="logo_width" xsi:type="number">283</argument> <!-- Add custom logo width -->
                <argument name="logo_height" xsi:type="number">85</argument> <!-- Add custom logo height -->
            </arguments>
        </referenceBlock>
    </body>
 </page>

the di.xml file in etc folder of my working module is as follows:

<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">Myvendor/mycustomadmintheme</item>
             </argument>
         </arguments>
    </type>
</config>

despite all this the logo stays the same. however when i open the logo image in new tab, i can see that the default magento logo is pulled from static/version1704465742/adminhtml/Myvendor/mycustomadmintheme/en_US/images/magento-logo.svg

So, the theme is working but the default.xml or admin_logo.xml is not. Can anyone tell me where i am going wrong, the magento version is 2.4

1
  • Hi, Could you please check the recent posted answer to your question. This will fix the issue. Jan 8 at 10:51

2 Answers 2

0

All Seems correct exclude:

No need of

app/design/adminhtml/Myvendor/mycustomadmintheme/Magento_Backend/layout/default.xml

Change file name from:

app/design/adminhtml/Myvendor/mycustomadmintheme/Magento_Backend/layout/admin_logo.xml to app/design/adminhtml/Myvendor/mycustomadmintheme/Magento_Backend/layout/admin_login.xml

Make Sure Your module, where you defined di.xml loading after Magento_Theme module prerequisites

A detail explanation about Admin Theme and update logo can be found on official ADOBE doc Link

0

There are two issues, and after the modifications, the logo will load properly.

First Issue:

I have utilized the same/your code and discovered that there is an code issue in your default.xml

Solution:

I have applied the following code in default.xml and the logo appears to load properly after admin login. Here is the default.xml code:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="header">
            <block class="Magento\Backend\Block\Page\Header" name="logo" before="-">
                <arguments>
                    <argument name="show_part" xsi:type="string">logo</argument>
                    <argument name="logo_image_src" xsi:type="string">images/admin-logo.png</argument>
                </arguments>
            </block>
        </referenceContainer>
    </body>
</page>

Second Issue:

The admin login file name is incorrect.

Solution:

Please rename admin_logo.xml to admin_login.xml as this file loads the logo on the Magento login screen. Other than that, the xml code is fine.

Note: I have tested the code changes on my end and everything seems to be working correctly.

Here are the screenshots: enter image description here

enter image description here

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.