在Magento中正确覆盖管理模板文件 [英] Properly override a admin template file in Magento

查看:64
本文介绍了在Magento中正确覆盖管理模板文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想正确覆盖此管理模板文件app/design/adminhtml/default/default/template/sales/order/create/form/address.phtml

I want to properly override this admin template file app/design/adminhtml/default/default/template/sales/order/create/form/address.phtml

找到的中,正确的方法是在新模块中创建布局文件,设置模板路径在我的模块目录中,并使用引用节点引用该模板文件.但是我不知道该怎么做.

From what I have found, the proper way is to create a layout file in a new module, set template path inside my module directory and reference that template file using reference node. But I have no clue how to do that.

到目前为止,我还不了解如何使用xml来控制布局.有人可以显示实际操作方法吗?

I don't understand how the layout is controlled using xml as of now. Can someone show how to actually do that?

推荐答案

您应该真正创建自己的模块,然后可以创建一个新模板.

You should really create your own module, which you can then create a new template.

如果要强制使用,则需要setTemplate(),它将phtml路径作为参数. $this->getLayout()->createBlock('my_module/blockname')->setTemplate('my_module/template.phtml');

If you want to force is you need setTemplate() which takes your phtml path as a param. $this->getLayout()->createBlock('my_module/blockname')->setTemplate('my_module/template.phtml');

请记住,这里的两个斜杠符号是不同的.

Bear in mind that the two slash notations here are different.

createBlock()用于块,因此将在/app/code/<codePool>/My/Module/Blocks/<blockname.php>

setTemplate()用于模板,因此将在/app/design/<area>/default/default/template/template.phtml

setTemplate() is for the template, so will be in /app/design/<area>/default/default/template/template.phtml

您的<area>将是/adminhtml,就像您在管理后端中一样.

Your <area> will be /adminhtml as you're in the admin backend.

为了使模板正常工作,您需要创建一个新模块并扩展使用该模板的adminhtml阻止文件.您必须从layout.xml中找到该块,然后才能扩展该块并指定一个新模板.

In order to get the template working you'll need to create a new module and extend the adminhtml block file which uses this template. You'll have to find the block from the layout.xml and then you can extend the Block and specify a new template.

这就是我要解决的方法,但是我真的发现很难覆盖Adminhtml模块中的内容.

That's how I'd go about it, but I'm also really finding it hard to override things in the Adminhtml module.

这篇关于在Magento中正确覆盖管理模板文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆