magento中的自定义模块不显示网格

时间:2013-06-11 14:35:39

标签: php magento magento-1.7 magento-1.4

我在magento admin中创建了一个自定义模块。问题是 grid.php Mage_Adminhtml_Block_Widget_Grid 扩展而不是显示网格(仅显示按钮和标题文本)。 grid.php的内容:

class Ha_Hvdmodule_Block_Adminhtml_Information_Grid extends Mage_Adminhtml_Block_Widget_Grid{
public function _construct(){
    parent::_construct();
    $this->setId('informationGrid');
    $this->setDefaultSort('id');
    $this->setDefaultDir('ASC');
    $this->setSaveParametersInSession(true);
}

protected  function _prepareCollection(){
    $collection = Mage::getModel('hvdmodule/information')->getCollection();
    $this->setCollection($collection);
    return parent::_prepareCollection();
}

protected function _prepareColumns(){
    $this->addColumn('id', array(
        'header' => Mage::helper('hvdmodule')->__('ID'),
        'align' => 'right',
        'width' => '10px',
        'index' => 'id',
    ));

    $this->addColumn('name', array(
        'header' => Mage::helper('hvdmodule')->__('Name'),
        'align' => 'left',
        'width' => '15px',
        'index' => 'name',
    ));

    $this->addColumn('content', array(
       'header' => Mage::helper('hvdmodule')->__('Content'),
        'align' => 'left',
        'width' => '20px',
        'index' => 'content',
    ));

    return parent::_prepareColumns();
}
}


?>

内容布局:

<?xml version="1.0"?>
 <layout>
 <hvdmodule_adminhtml_information_index>
    <reference name="content">
        <block type="hvdmodule/adminhtml_information" name="information"/>
    </reference>
</hvdmodule_adminhtml_information_index>
</layout>

内容控制器:

class Ha_Hvdmodule_Adminhtml_InformationController extends Mage_Adminhtml_Controller_Action{

public function indexAction(){
    $this->loadLayout();
    $this->renderLayout();
}

}

1 个答案:

答案 0 :(得分:0)

您是否将信息块设置为容器?

class Ha_Hvdmodule_Block_Adminhtml_Information extends Mage_Adminhtml_Block_Widget_Grid_Container 
{
    public function __construct()
    {        
        $this->_controller = 'adminhtml_information';
        $this->_blockGroup = 'information';

        $this->_headerText = Mage::helper('module')->__('title');
        $this->_addButtonLabel = Mage::helper('module')->__('Add Item');

        parent::__construct();
    }
}