3

I have created a adminhtml theme but it's throwing error. Could you please clarify me where I went wrong?

my code is:

root/app/design/adminhtml/Magento/backend/composer.json

{
    "name": "magento/theme-adminhtml-backend",
    "description": "N/A",
    "require": {
        "php": "~5.5.0|~5.6.0|~7.0.0",
        "magento/framework": "100.0.*"
    },
    "type": "magento2-theme",
    "version": "100.0.2",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "autoload": {
                 "files": [
             "registration.php"
         ]
     }

}

root/app/design/adminhtml/Magento/backend/registration.php

<?php
    /**
     * Copyright © 2015 Magento. All rights reserved.
     * See COPYING.txt for license details.
     */

\Magento\Framework\Component\ComponentRegistrar::register(
        \Magento\Framework\Component\ComponentRegistrar::MODULE,
        'adminhtml/Magento/backend',
        __DIR__
    );

root/app/design/adminhtml/Magento/backend/theme.xml

<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Magento 2 backend</title>
</theme>

Could you please clarify me where I went wrong?

1

Your registration.php file has declared the wrong type; You need to change it to;

\Magento\Framework\Component\ComponentRegistrar::THEME

Because you have declared it as ::MODULE it is looking for the module.xml definition.

  • I have changed but still it's throwing error this module already exist. Can you please post a example of code – Manoj Kumar Feb 4 '16 at 12:52
  • That's because the module does already exist :) The default backend module is called "adminhtml/Magento/backend" so you need to call it something else. – Smartie Feb 4 '16 at 12:55
1

In your theme: registration.php

<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'adminhtml/CompanyName/backend',
    __DIR__
);

theme.xml Note how the parent theme has been defined

<!--
/**
 * Copyright © 2017 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>CompanyName BackendTheme</title>
    <parent>Magento/backend</parent>
</theme>

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.