Magento - 覆盖 Adminhtml 块
我花了几个小时试图覆盖扩展程序中添加商店"和编辑商店"页面的 Magento 块,以向其中添加另一个文本框.在浏览了书籍和谷歌搜索之后,我找到了几个人们说有效的解决方案,但不适合我.
I've spent hours trying to override the Magento block for the "Add store" and "Edit store" pages in an extension, to add another text box to it. After Going through books and Googling, I've found several solutions which people say are working, however not for me.
一个推荐是这个.
我从 Lee Saferite 那里复制了所谓正确的解决方案,该解决方案适用于原始海报,但不适用于我.当然,我将值更改为我要覆盖的类和新修改的类.
I've copied the supposedly correct solution from Lee Saferite which works for the original poster but not for me. Of course, I changed the values to the class I'm overriding and the new modified class.
我的 config.xml(相关部分):
My config.xml (the relevant part):
<global>
<blocks>
<adminhtml>
<rewrite>
<system_store_sdit_form>Nintera_General_Block_StoreEdit</system_store_sdit_form>
</rewrite>
</adminhtml>
</blocks>
<resources></resources>
<helpers>
<Nintera_General>
<class>Nintera_General_Helper</class>
</Nintera_General>
</helpers>
</global>
以及位于 Nintera/General/Block/StoreEdit.php 的块类:
And the block class located at Nintera/General/Block/StoreEdit.php:
class Nintera_General_Block_StoreEdit extends Mage_Adminhtml_Block_System_Store_Edit_Form
{
/**
* Prepare form data
*
* return Mage_Adminhtml_Block_Widget_Form
*/
protected function _prepareForm()
{ ... }
}
这个类包含新的输入字段.如果我在以下位置修改原始核心文件,这些字段会完美显示:
This class contains new input fields. The fields show up perfectly if I modify the original core file at:
app/core/Mage/Adminhtml/Block/System/Store/Edit.php
app/core/Mage/Adminhtml/Block/System/Store/Edit.php
但我真的希望我的扩展程序覆盖它.如有必要,我可以发布我的整个 config.xml,但它主要是创建顶级管理菜单并指定扩展信息,其他不多.
But I really want my extension to override it. If necessary I can post my entire config.xml but it's mostly creating a top level admin menu and specifies extension info, not much else.
对出了什么问题有什么想法吗?非常感谢解决方案!
Any ideas on what goes wrong? A solution would be HIGHLY appreciated!
推荐答案
如下图,略有修改.您似乎将edit"拼错为sdit".
Shown below, with a slight modification. It appears that you've misspelt "edit" as "sdit".
<global>
<blocks>
<adminhtml>
<rewrite>
<system_store_edit_form>Nintera_General_Block_StoreEdit</system_store_edit_form>
</rewrite>
</adminhtml>
</blocks>
</global>
另外请记住,如果您想使用 Mage::getModel("nintera_general/myblock") 语法调用其他块,您还需要将自己的块添加到该代码中,如下所示.
Also keep in mind that if you want to call other blocks using the Mage::getModel("nintera_general/myblock") syntax, you'll need to add your own blocks to that code as well, as shown below.
<global>
<blocks>
<adminhtml>
<rewrite>
<system_store_edit_form>Nintera_General_Block_StoreEdit</system_store_edit_form>
</rewrite>
</adminhtml>
<nintera_general>
<class>Nintera_General_Block</class>
</nintera_general>
</blocks>
</global>
相关文章