First of all I'm trying to load grid container and show container heading. My block file is working fine.
Container path is Super->Awesome->Block->Adminhtml->Awesome.php which contains
<?php
class Super_Awesome_Block_Adminhtml_Awesome extends Mage_Adminhtml_Block_Widget_Grid_Container
{
public function __construct()
{
$this->_blockGroup = 'super_awesome';
$this->_controller = 'adminhtml_awesome';
$this->_headerText = Mage::helper('super_awesome')->__('Manage');
parent::__construct();
}
}
layout file super_awesome.xml
<?xml version="1.0"?>
<layout>
<adminhtml_example_index>
<reference name="content">
<block type="super_awesome/adminhtml_awesome" name="super_awesome"></block>
</reference>
</adminhtml_example_index>
</layout>
If I echo something inside public function __construct()
, it's showing content but on adding proper __contruct()
method as above it's showing a blank page.
Do I need to add internal block(Grid.php) also, then my container text will appear? Container block Awesome.php should be changed to Grid.php?
Config.xml
<?xml version="1.0"?>
<config>
<modules>
<Super_Awesome>
<version>0.1.0</version>
</Super_Awesome>
</modules>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<super_awesome before="Mage_Adminhtml">Super_Awesome</super_awesome>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<adminhtml>
<layout>
<updates>
<super_awesome>
<file>super_awesome.xml</file>
</super_awesome>
</updates>
</layout>
</adminhtml>
<global>
<blocks>
<super_awesome>
<class>Super_Awesome_Block</class>
</super_awesome>
</blocks>
<helpers>
<super_awesome>
<class>Super_Awesome_Helper</class>
</super_awesome>
</helpers>
</global>
</config>
Best Answer
The code you are adding in your __construct method sets the details for the internal block that I think you are missing.
Those settings are used in the parents _prepareLayout() method as below.
For you this bit of code will end up as
Which means you need to create the block
Super_Awesome_Block_Adminhtml_Awesome_Grid
which should extendMage_Adminhtml_Block_Widget_Grid
.Mage_Adminhtml_Block_Poll_Grid
could be used as an example for this missing grid block.