搜索须要修改的后台模板位置,后台打开 Enabled Template Path Hints for Admin,会显示全部模板位置,以order信息页面为例,位置是:vendor/magento/module-sales/view/adminhtml/templates/order/view/info.phtml
html
搜索全部adminhtml layout文件,关键字是"order/view/info.phtml",会找到如下layoutvendor/magento/module-sales/view/adminhtml/layout/sales_order_view.xml
缓存
可知该模板的layout代码是:app
<block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="order/view/info.phtml"/>
最终目标是修改block的template参数,能够用layout重写机制实现,须要建立并安装一个module。重写layout的位置:app/code/<Vendor>/<Module>/view/adminhtml/layout/sales_order_view.xml
spa
要重写指定的block,上下级结构也不能少code
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="left"> <referenceBlock name="sales_order_tabs"> <referenceBlock name="order_tab_info"> <referenceBlock name="order_info" template="<Module>::order/view/info.phtml"/> </referenceBlock> </referenceBlock> </referenceContainer> </body> </page>
原始模板复制到 app/code/<Vendor>/<Module>/view/adminhtml/templates/order/view/info.phtml
下,就能够进行修改。清除缓存后就会生效xml