我正在尝试创建自定义模块。当我单击模块菜单时,空网格为displaying。日志未显示任何错误
Grid.php
class Training_Banners_Block_Adminhtml_Banners_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('bannersGrid');
$this->setDefaultDir('ASC');
$this->setDefaultSort('banner_id');
$this->setSaveParamatersInSession(true);
}
protected function _prepareCollection()
{
$collection=Mage::getModel('banners/manage')->getCollection();
$this->setCollection($collection);
Mage::log(var_dump($collection));
return $collection;
}
protected function _prepareColumns()
{
$this->addColumn('banner_id', array(
'header' => Mage::helper('banners')->__('ID'),
'align' =>'right',
'width' => '50px',
'index' => 'banner_id'
));
$this->addColumn('name', array(
'header' => Mage::helper('banners')->__('Name'),
'align' =>'left',
'index' => 'name'
));
return parent::_prepareColumns();
}
}
banners.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<adminhtml_banners_index>
<reference name="content">
<block type="banners/adminhtml_banners" name="training.banners" />
</reference>
</adminhtml_banners_index>
</layout>
控制器
<?php
class Training_Banners_Adminhtml_BanneradminController extends Mage_Adminhtml_Controller_Action
{
public function _initAction()
{
$this->loadLayout()->_setActiveMenu('banners/banners')
->_addBreadcrumb(Mage::helper('adminhtml')->__('Banners Manager'), Mage::helper('adminhtml')->__('Banners Manager'));
return $this;
}
public function indexAction()
{
$this->_initAction();
$this->loadLayout();
$this->_addContent($this->getLayout()->createBlock('banners/adminhtml_banners'));
$this->renderLayout();
}
}
答案 0 :(得分:2)
首先请清除您的缓存,然后注销并登录。
另外请检查config.xml文件,块和其他声明是否相同..