php – Magento – 覆盖Adminhtml块

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – Magento – 覆盖Adminhtml块脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我花了好几个小时试图覆盖扩展中“添加商店”和“编辑商店”页面的Magento块,以便为其添加一个文本框.经过书籍谷歌搜索后,我发现了一些人们认为有效的解决方案,但不适合我.

一项建议是this one.

我复制了Lee SaferITe所谓的正确解决方案,该解决方案适用于原始海报但不适用于我.当然,我将值更改为我重写的类和新修改的类.

我的config.XMl(相关部分):

<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

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()
    { ... }
}

该类包含新的输入字段.如果我在以下位置修改原始核心文件,则字段会完美显示

应用程序/核心/法师/ Adminhtml /模块/系统/存储/ Edit.PHP

但我真的希望我的扩展能够覆盖它.如果有必要,我可以发布我的整个config.xml,但它主要创建一个顶级管理菜单,并指定扩展信息,而不是其他.

关于出了什么问题的任何想法?一个解决方案将非常感谢!

如下所示,稍作修改.看来你拼错了“编辑”为“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”)语法调用其他块,则还需要将自己的块添加到该代码中,如下所示.

<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>

脚本宝典总结

以上是脚本宝典为你收集整理的php – Magento – 覆盖Adminhtml块全部内容,希望文章能够帮你解决php – Magento – 覆盖Adminhtml块所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。