0

I tried to create an admin theme and make an override to sales module template file but this don't work, i followed those tutorials : create admin theme and Apply custom admin theme

in app/design/adminhtml/Vendor/customtheme, i created registration.php

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
use \Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::THEME, 'adminhtml/Vendor/customtheme', __DIR__);

in app/design/adminhtml/Vendor/customtheme/theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
     <title>Custom Theme</title> <!-- your theme's name -->
     <parent>Magento/backend</parent> <!-- the parent theme. Example: Magento/backend -->
</theme>

In app/design/adminhtml/Vendor/customtheme/Module_Sales/templates/order/view/info.phtml i tried to add 'ddddd' in table header for customer acount data

  <?php foreach ($block->getCustomerAccountData() as $data):?>
                    <tr>
                        <th><?= $block->escapeHtml($data['label']) ?> ddddd</th>
                        <td><?= $block->escapeHtml($data['value'], ['br']) ?></td>
                    </tr>
                <?php endforeach;?>
                <?= $block->getChildHtml('extra_customer_info') ?>

After that i tried to create a module to apply the new theme admin

in app/code/Vendor/ThemeAdmin/registration.php

<?php

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

in Vendor/ThemeAdmin/composer.json

{
"name": "vendor/themeadmin",
"description": "new theme admin",
"require": {
    "php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0"
},
"type": "magento2-module",
"license": [
    "OSL-3.0",
    "AFL-3.0"
],
"autoload": {
    "files": [ "registration.php" ],
    "psr-4": {
        "Vendor\\ThemeAdmin\\": ""
    }        
}
}

In Vendor/ThemeAdmin/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="Vendor_ThemeAdmin" setup_version="1.0.0">
        <sequence>>
            <module name="Magento_Theme"/>
        </sequence>
    </module>
</config>

In Wetag/ThemeAdmin/etc/adminhtml/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">

<!-- Admin theme. Start -->
<type name="Magento\Theme\Model\View\Design">
    <arguments>
        <argument name="themes" xsi:type="array">
            <item name="adminhtml" xsi:type="string">Vendor/customtheme</item>
        </argument>
    </arguments>
</type>
<!-- Admin theme. End -->
</config>
4
  • You can override the required template in your custom module, is there any specific requirement of creating admin theme? – Rahul Barot Mar 12 at 13:11
  • Did you run php bin/magento s:up after setup the new theme? – Petro Chaikivskyi Mar 12 at 14:50
  • @RahulBarot i did this and it works but firstly i tried to create a new admin theme and override a module template but it doesn't work – tarek fellah Mar 12 at 15:04
  • @PetroChaikivskyi yes i did with clearing cache and command setup:di:compile – tarek fellah Mar 12 at 15:04
0

Template override is not working because you are overriding it in wrong directory, theme creation is fine.

In app/design/adminhtml/Vendor/customtheme/Module_Sales/templates/order/view/info.phtml i tried to add 'ddddd' in table header for customer acount data

It should be Magento_Sales, try renaming it and then check.

Thanks!

1
0

If you want to make a theme then do it in the design folder and also there is no need of creating a theme for running the di.xml file and also check the Magento luma theme in that also you won't find any di.xml file.

The theme contains only the view part of a module for a particular . That much think if wrong then please correct me

Please use a custom module and override it with that

Happy Coding

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.