我希望了解两件事:
-
扩展Magento 2 Admin CSS(或者做更少的正确方法?)从原始后端复制CSS / less
-
在后端覆盖,例如:Sales> Orders>被调用文件vendor / magento / module-backend / view / adminhtml / templates / pageactions.phtml
我跟着http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/themes/admin_theme_create.html&http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/themes/admin_theme_apply.html
检查了不同的stackoverflow帖子
Magento 2.0 override admin css (style.css)
但是我现在正好理解这一点 .
我希望覆盖magento登录的CSS,例如 . 我何时使用应用程序/代码,何时使用应用程序/设计以及出于什么原因?在这个例子中 I'm trying both and I'm not sure where to place what where for what reason. Some posts refer to overriding through app/code, but my app/design css change works too, which is correct?
我成功地为后端创建了一个自定义页面,通过这个模块,我还通过di.xml激活自定义adminhtml模板,并在管理员登录时显示我自己的徽标,这样才有效,我也有自定义CSS . 我不会打扰你工作的部分,所以我将保留Index.php,menu.xml,routes.xml,exampleadminnewpage_helloworld_index和模板中的文件,因为它工作正常 .
应用/代码文件结构
app/code/Vendor
└── ExampleAdminNewPage
├── composer.json
├── Controller
│ └── Adminhtml
│ └── HelloWorld
│ └── Index.php
├── etc
│ ├── adminhtml
│ │ ├── menu.xml
│ │ └── routes.xml
│ ├── di.xml
│ └── module.xml
├── registration.php
└── view
└── adminhtml
├── layout
│ └── exampleadminnewpage_helloworld_index.xml
└── templates
├── helloworld.phtml
├── intro.css
└── js.phtml
应用程序/代码/供应商/ ExampleAdminNewPage的/ etc / di.xml
<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">Vendor/Test_Admin</item>
</argument>
</arguments>
</type>
</config>
应用程序/代码/供应商/ ExampleAdminNewPage /和registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Vendor_ExampleAdminNewPage',
__DIR__
);
应用程序/代码/供应商/ ExampleAdminNewPage的/ 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_ExampleAdminNewPage" setup_version="1.0.0">
<sequence>
<module name="Magento_Backend"/>
</sequence>
</module>
</config>
app /设计文件结构
app/design/adminhtml/Vendor
└── Test_Admin
├── Magento_Sales
│ └── templates
│ ├── items
│ │ └── column
│ │ └── name.phtml
│ └── pageactions.phtml
├── registration.php
├── theme.xml
└── web
├── css
│ └── styles.css
├── images
│ └── magento-logo.svg > This is my own logo and this shows at the admin login!
└── js
└── requirejs-config.js
The following echo doesn't work, I had expected that if I went to sales>orders, I'd see this echo? app / design / adminhtml / Vendor / Test_Admin / Magento_Sales / templates / items / column / name.phtml
<?php echo 'test'; ?>
Same goes for this echo, I expected to see the echo at Sales>Orders
应用程序/设计/ adminhtml /供应商/ Test_Admin / Magento_Sales /模板/ pageactions.phtml
<?php echo 'testpageaction'; ?>
The CSS works, but am I supposed to do it through this way? And where can I find the original back-end css/less?
应用程序/设计/ adminhtml /供应商/ Test_Admin /网络/ CSS / styles.css的
span {
background-color: red !important;
}
我也不知道如何让JS工作,目前我有 . 应用程序/设计/ adminhtml /供应商/ Test_Admin /网络/ JS / requirejs-config.js
var config = {
map: {
'*': {
customAdmin: 'Vendor_Test_Admin/js/customAdmin'
}
},
deps: ["jquery"]
};
应用程序/设计/ adminhtml /供应商/ Test_Admin /和registration.php
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
'adminhtml/Vendor/Test_admin', // Example: 'adminhtml/Magento/backend'
__DIR__
);
的public_html /应用程序/设计/ adminhtml /供应商/ Test_Admin / theme.xml
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>Test_Admin Theme</title> <!-- your theme's name -->
<parent>Magento/backend</parent> <!-- the parent theme. Example: Magento/backend -->
</theme>
我希望我的问题很明确,对我来说有点不清楚,这就是为什么我可能无法正确说出来但我希望我现在拥有的就足够了 .