我正在按照本教程http://codemagento.com/2011/03/creating-custom-magento-reports/创建简单的报告模块。我有所有的代码和 XML,但我收到了这个错误
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>
文件:app/code/local/Super/Awesome/Block/Adminhtml/Report/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');
}
}