我正在關注本教程http://codemagento.com/2011/03/creating-custom-magento-reports/創建簡單報告模塊。我已經具備了所有的代碼和XML,但我收到此錯誤未在magento中找到已定義的塊
2012-05-31T21:48:43+00:00 ERR (3): Recoverable Error: Argument 1 passed to Mage_Adminhtml_Controller_Action::_addContent() must be an instance of Mage_Core_Block_Abstract, boolean given, called in /var/www/magento/app/code/local/Super/Awesome/controllers/Adminhtml/Report/ExampleController.php on line 22 and defined in /var/www/magento/app/code/core/Mage/Adminhtml/Controller/Action.php on line 112
的結構看起來像這樣
Super
|_ Awesome
|_Block
| |_Adminhtml
| |_Report
| |_Simple
| | |_Grid.php
| |_Simple.php
|_controllers
| |_Adminhtml
| |_Report
| |_ExampleController.php
|_etc
| |_adminhtml.xml
| |_config.xml
|_Helper
| |_Data.php
|_Model
|_Mysql4
| |_Report
| | |_Simple
| | |_Collection.php
| |_Simple.php
|_Simple.php
我認爲它是沒有找到塊代碼,但爲什麼呢?
編輯
<?xml version="1.0"?>
<config>
<modules>
<Super_Awesome>
<version>0.1.0</version>
</Super_Awesome>
</modules>
<admin>
<!--
Here we are telling the Magento router to look for the controllers in the Super_Awesome_controllers_Adminhtml before we look in the
Mage_Adminhtml module for all urls that begin with /admin/controller_name
-->
<routers>
<adminhtml>
<args>
<modules>
<awesome before="Mage_Adminhtml">Super_Awesome_Adminhtml</awesome>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<models>
<awesome>
<class>Super_Awesome_Model</class>
<resourceModel>awesome_mysql4</resourceModel>
</awesome>
<awesome_mysql4>
<class>Super_Awesome_Model_Mysql4</class>
<entities>
<simple>
<table>super_awesome_example_simple</table>
</simple>
</entities>
</awesome_mysql4>
</models>
<global>
<resources>
<awesome_setup>
<setup>
<module>Super_Awesome</module>
<class>Super_Awesome_Model_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</awesome_setup>
<awesome_write>
<connection>
<use>core_write</use>
</connection>
</awesome_write>
<awesome_read>
<connection>
<use>core_read</use>
</connection>
</awesome_read>
</resources>
<helpers>
<awesome>
<class>Super_Awesome_Helper</class>
</awesome>
</helpers>
</global>
</config>
文件:應用程序/代碼/本地/超級/真棒/座/ Adminhtml /報告/ Simple.php
class Super_Awesome_Block_Adminhtml_Report_Simple extends Mage_Adminhtml_Block_Widget_Grid_Container
{
public function __construct()
{
$this->_blockGroup = 'awesome';
$this->_controller = 'adminhtml_report_simple';
$this->_headerText = Mage::helper('awesome')->__('Simple Report');
parent::__construct();
$this->_removeButton('add');
}
}
似乎
並在必要時,使法師顯示通過改變錯誤的index.php:
所以下面法師::日誌更好的使用是非常重要和有益的就像錯誤非常簡單。所需的參數類型是Mage_Core_Block_Abstract,但是您將它傳遞給布爾值。它似乎找到你的課程,但它有這個錯誤。你確定教程和你的法師版本是兼容的嗎?將代碼第22行放在控制器中以獲得進一步的幫助... – Bosworth99
您正確的是它沒有找到塊。 '$ this-> getLayout() - > createBlock('awesome/adminhtml_report_simple')'返回'false'。您需要發佈您的'config.xml'和'Super_Awesome_Block_Adminhtml_Report_Simple'代碼,並確認文件名/路徑是否正確,然後才能提供幫助。 – nachito
Config.xml和Super_Awesome_Block_Adminhtml_Report_Simple類添加了 – Clutch