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 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用