Magento-覆盖Adminhtml块 [英] Magento - overriding Adminhtml block

查看:86
本文介绍了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")语法调用其他块,则还需要向该代码中添加自己的块,如下所示. /p>

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>

这篇关于Magento-覆盖Adminhtml块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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