搜索須要修改的後臺模板位置,後臺打開 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