如何覆盖 magento 中的管理模板文件? [英] How to override the admin template file in magento?
问题描述
我需要覆盖adminhtml/sales/order/create/items/grid.phtml"文件以在从管理员创建新订单时在每个项目下显示一些自定义文本.我希望这通过自定义模块来完成.任何人都可以建议如何覆盖管理模板文件?非常感谢任何帮助
I need to override the "adminhtml/sales/order/create/items/grid.phtml" file to display some custom text under each item while creating new order from admin. I want this to be done through custom module. Anyone can suggest how to override the admin template files? Any help is really appreciated
推荐答案
我建议您使用 adminhtml 部分的布局更新创建一个新模板并在您的模块中添加新设计.例如:
I Recommend you that create a new template and add new design in your module with the layout update for the adminhtml section. For example:
在自定义扩展的 config.xml 中,您可以使用以下内容更新 adminhtml 的布局:
In your config.xml of your custom extension you can update the layout of adminhtml with:
<adminhtml>
<layout>
<updates>
<adminhtml>
<file>yourcustomlayout.xml</file>
</adminhtml>
</updates>
</layout>
</adminhtml>
好的,那么既然这样布局你就可以写下一个代码来添加一个css例如:
Ok, then since this layout you can write the next code to add a css for example:
<layout>
<default>
<reference name="head">
<action method="addCss">
<name>aw_all/css/window.css</name>
</action>
</reference>
</default>
</layout>
在您的情况下,您需要为您的块添加自定义模板
In your case you need add you custom template for your block
<layout>
<handle>
<reference name="content">
<block type="smspremium/adminhtml_smspremium" name="smspremium">
<action method="setTemplate">
<template>customtemplate.phtml</template>
</action>
</block>
</reference>
</handle>
</layout>
如果您想丢弃所有块并替换为您的块,您可以设置为 unsetChild
If you want to discart all the block and replace with your block you can made unsetChild
<layout>
<handle>
<reference name="content">
<action method="unsetChild"><name>your.last.block</name></action>
<block type="smspremium/adminhtml_smspremium" name="smspremium">
<action method="setTemplate">
<template>customtemplate.phtml</template>
</action>
</block>
</reference>
</handle>
</layout>
这项工作与前端布局相同,只是由于您存储文件的目录不同.对于模板:
This work same the frontend layout, only with the diference of the directory since you store your files. For Templates:
app/design/adminhtml/default/default/templates
对于布局:
app/design/adminhtml/default/default/layout
希望能帮到你
这篇关于如何覆盖 magento 中的管理模板文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!