1

私はこれで数時間過ごしました。Magento は、自分のブロックではなく、Mage 名前空間から自分のブロックを呼び出そうとし続けます。

エラー: /Library/WebServer/Documents/magento/app/Mage.php:594 のメッセージ「無効なブロック タイプ: Mage_Newcart_Block_Adminhtml_Igrid」を含む例外「Mage_Core_Exception」

私は問題を見つけようとしていたるところを見てきました。私はそれが私のレイアウトに到達し、ハンドルが機能することを知っています:

<?xml version="1.0"?>

<layout version="0.1.0">

      <images_adminhtml_index_index>
           <reference name="content">
                  <block type="newcart/adminhtml_igrid"  name="adminblock" />
           </reference>
      </images_adminhtml_index_index>
</layout>

ただし、私のブロック (実際にはグリッド コンテナー) は適切な名前空間から呼び出されません。

app/code/local/[名前空間]/Newcart/Block/Adminhtml/Igrid.php

class [Namespace]_Newcart_Block_Adminhtml_Igrid extends Mage_Adminhtml_Block_Widget_Grid_Container
{
    public function __construct()
    {

     $this->_controller = 'adminhtml_imagegrid';
     $this->_blockGroup = 'newcart';
     $this->_headerText = 'Images';
     $this->_addButtonLabel = 'Add an Image';

     parent::__construct();
     }

     protected function _prepareLayout()
     {
         //Mage::log($this->createBlock( $this->_blockGroup.'/' . $this->_controller . '_grid',
         //   $this->_controller . '.grid'), null, ‘layout.log’ );
        $this->setChild( 'grid',
            $this->getLayout()->createBlock( $this->_blockGroup.'/' . $this->_controller . '_grid',
            $this->_controller . '.grid')->setSaveParametersInSession(true) );
        return parent::_prepareLayout();
     }
}

注: Imagegrid は同じディレクトリ内のファイルです。'$this->_controller = 'adminhtml_igrid';' を試しましたが、問題は解決しませんでした。

構成:

<?xml version="1.0"?>

  <config>
     <modules>
        <[namespace]_Newcart>
          <version>0.1.0</version>
        </[namespace]_Newcart>
     </modules>
     <admin>
        <routers>
            <images>
                <use>admin</use>
                <args>
                    <module>[namespace]_Newcart</module>
                    <frontName>imageadmin</frontName>
                </args>
            </images>
        </routers>
    </admin>
    <adminhtml>
        <layout>
            <updates>
                <images>
                    <file>images.xml</file>
                </images>
            </updates>
        </layout>
    </adminhtml>
    <global>
        <blocks>
            <[namespace]_newcart>
                <class>[namespace]_Newcart_Block</class>
            </[namespace]_newcart>
        </blocks>
        <models>
            <images>
                <class>[namespace]_Newcart_Model</class>
                <resourceModel>image_resource</resourceModel>
            </images>  
            <image_resource>
                <class>[namespace]_Newcart_Model_Resource</class>
                <entities>
                    <imagemodel>
                        <table>nw_images</table>
                    </imagemodel>
                </entities>
            </image_resource>
        </models>
    </global>
</config>

私はどこでも原因を探しましたが、他にどこでエラーを探すべきかわかりません。助けてください!!!

4

2 に答える 2

1

答え (ありがとう、ivantedja!)

「[namespace]_newcart」ではなく、「newcart」にする必要があります (ブロック ノードでは、名前空間を指定する必要はありません)。

于 2012-09-24T19:11:00.513 に答える
0

モジュールのconfig.xmlに次のコードを追加するだけです。

<config>
    ...
    <global>
        ...
        <blocks>
            <[namespace]_newcart>
                <class>[Namespace]_Newcart_Block</class>
            </[namespace]_newcart>
        </blocks>
        ...
    </global>
    ...
</config>
于 2012-09-21T22:05:51.377 に答える