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>
有帮助吗?

解决方案

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!

其他提示

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

许可以下: CC-BY-SA归因
scroll top