【问题标题】:Magento, override custom modules adminhtml blockMagento,覆盖自定义模块 adminhtml 块
【发布时间】:2014-08-12 09:01:26
【问题描述】:

我正在尝试覆盖自定义模块 adminhtml 块。该块是一个 adminhtml 选项卡/表单块。

如果我重写正确,我会从关联的 tabs.php 块中得到一个错误...在 beforeHtml() 函数中。

这是我认为可以很好地重写的代码:

   <blocks>
        <devaf>
            <class>Dev_Affil_Block</class>
        </devaf>
        <affiliateplus>
            <rewrite>
                <adminhtml_account_edit_tab_form>
                    Dev_Affil_Block_Adminhtml_Account_Edit_Tab_Form
                </adminhtml_account_edit_tab_form>
            </rewrite>
        </affiliateplus>
    </blocks>

实际错误是:

    20  3.5764  29562296    Mage_Core_Block_Abstract->toHtml( ) ..\List.php:43
    21  3.5767  29562448 Magestore_Affiliateplus_Block_Adminhtml_Account_Edit_Tabs->_beforeToHtml( )    ..\Abstract.php:862


  exception 'Mage_Core_Exception' with message 'Invalid block type: Dev_Affil_Block_Adminhtml_Account_Edit_Tab_Form

我相信错误是在这里引起的...尝试初始化块:

文件:Magestore_Affiliateplus_Block_Adminhtml_Account_Edit_Tabs

   $this->addTab('general_section', array(
        'label'     => Mage::helper('affiliateplus')->__('General Information'),
        'title'     => Mage::helper('affiliateplus')->__('General Information'),
        'content'   =>  $this->getLayout()->createBlock('affiliateplus/adminhtml_account_edit_tab_form')->toHtml(),
    ));

我的自定义表单类,扩展了我试图覆盖/覆盖的类。

 class Dev_Affil_Block_Adminhtml_Account_Edit_Tab_Form extends Magestore_Affiliateplus_Block_Adminhtml_Account_Edit_Tab_Form {

我也尝试过扩展通常的 Mage 类...这也没有用。

 class Dev_Affil_Block_Adminhtml_Account_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {

我在这个类中有一个调试 stmt,一旦我能得到那个 stmt 输出,我应该没问题。

任何人有任何想法/提示?

谢谢 S

【问题讨论】:

  • Dev_Affil_Block_Adminhtml_Account_Edit_Tab_Form 扩展了哪个类?也许您也可以将该声明添加到您的问题中。

标签: php magento overriding block admin


【解决方案1】:
 <rewrite>
    <class_to_override>
        my_class
    </class_to_override>
 </rewrite>

应该是:

 <rewrite>
    <class_to_override>my_class</class_to_override>
 </rewrite>

它应该扩展:

 Mage_Adminhtml_Block_Widget_Form

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-03
    • 2012-02-18
    • 1970-01-01
    • 1970-01-01
    • 2014-07-09
    • 2016-01-16
    • 2015-09-09
    相关资源
    最近更新 更多