dongyuhui0418 2015-11-19 09:37
浏览 44
已采纳

adminhtml_sales_order_view中的addTab:“无效的块类型:Mage_ ...”

Edit: Additionally to the code below, I have also tried to do exactly what this tutorial tells: http://www.magentothemess.com/archives/1267 Magento still wants to call a block, which name begins with "Mage_" :(

Original Post

I've tried so many tutorials, but Magento is still saying the same:

Invalid Blocktype: Mage_AdminModifications_Block_Adminhtml_Sales_Order_View_Tab_Custom.php

What I've done?

code/local/MyNamespace/AdminModifications/etc/config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <MyNamespace_AdminModifications>
      <version>1.0</version>
    </MyNamespace_AdminModifications>
  </modules>
  <global>
    <blocks>
      <MyNamespace_AdminModifications>
        <class>MyNamespace_AdminModifications_Block</class>
      </MyNamespace_AdminModifications>
    </blocks>
    <models>
        <MyNamespace_AdminModifications>
            <class>MyNamespace_AdminModifications_Model</class>
        </MyNamespace_AdminModifications>
    </models>
  </global>
  <adminhtml>
    <layout>
      <updates>
          <MyNamespace_AdminModifications>
              <file>adminmodifications.xml</file>
          </MyNamespace_AdminModifications>
      </updates>
    </layout>
  </adminhtml>
</config>

design/adminhtml/default/default/layout/adminmodifications.xml

<?xml version="1.0"?>
<layout>
    <adminhtml_sales_order_view>
        <reference name="sales_order_tabs">
            <action method="addTab">
                <name>order_custom</name>
                <block>AdminModifications/adminhtml_sales_order_view_tab_custom</block>
            </action>
        </reference>
    </adminhtml_sales_order_view>
</layout>

code/local/MyNamespace/AdminModifications/Block/Adminhtml/Sales/Order/View/Tab/Custom.php

<?php
class MyNamespace_AdminModifications_Block_Adminhtml_Sales_Order_View_Tab_Custom
    extends Mage_Adminhtml_Block_Template
    implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
    protected $_chat = null;

    protected function _construct()
    {
        parent::_construct();
        $this->setTemplate('custom/tab.phtml');
    }

    public function getTabLabel() {
        return $this->__('Custom Tab');
    }

    public function getTabTitle() {
        return $this->__('Custom Overview');
    }

    public function canShowTab() {
        return true;
    }

    public function isHidden() {
        return false;
    }

    public function getOrder(){
        return Mage::registry('current_order');
    }

design/adminhtml/default/default/template/custom/tab.phtml (jus copied from somewhere for testing)

<?php
/**
 * Custom tab template
 */
?>
<div class="input-field">
 <label for="custom_field">Custom Field</label>
 <input type="text" class="input-text" name="custom_field" id="custom_field" />
</div>

Where is my mistake hidden?

  • 写回答

1条回答 默认 最新

  • duanbeng8872 2015-11-19 12:44
    关注

    AdminModifications -> MyNamespace_AdminModifications

            <action method="addTab">
                <name>order_custom</name>
                <block>MyNamespace_AdminModifications/adminhtml_sales_order_view_tab_custom</block>
            </action>
    

    because

    <blocks>
      <MyNamespace_AdminModifications>
        <class>MyNamespace_AdminModifications_Block</class>
      </MyNamespace_AdminModifications>
    </blocks>
    

    Tip for the future: if you ever see magento trying to load Mage_* class instead of your class - 99% that you have an error in your config.xml file or typo in calling a block/model/helper by config name (like <MyNamespace_AdminModifications> in this case)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀