Why does my Block not get loaded?

36 views Asked by At

I don't know why my block does not get loaded. I already cleared the cache (incl var/cache). Can someone help me figure out what I missed? However, the Here: shows up!

here is my layout xml: app/design/adminhtml/default/default/template/gpa/items.phtml

<?xml version="1.0"?>
<layout>
    <gpa_adminhtml_gpa_index>
        <reference name="content">
            <block type="core/template" name="gpa" template="gpa/items.phtml" />
        </reference>
    </gpa_adminhtml_gpa_index>
</layout>

items.phtml content: Here: <?php echo $this->getItems() ?>

block definition:

class Mymodulenamespace_Gpa_Block_Adminhtml_Gpa extends Mage_Core_Block_Template {
    public function getItems() {
        echo 'ABCDEF';
    }
}

here is my controller:

class Mymodulenamespace_Gpa_Adminhtml_GpaController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction() {
        $this->loadLayout();
        $this->renderLayout();
    }
}

I can see the output "Here:" so I know my Controller is being loaded correctly and the layout xml is also correct. But why isn't my Block getting instantiated?

1

There are 1 answers

0
zokibtmkd On BEST ANSWER

Can you please change Mage_Core_Block_Template with Mage_Adminhtml_Block_Template and instead of defining XML layout, try this:

class Mymodulenamespace_Gpa_Block_Adminhtml_Gpa extends Mage_Adminhtml_Block_Template {
    protected function _construct()
    {
        $this->setTemplate('gpa/items.phtml');
        parent::_construct();
    }
    public function getItems() {
        echo 'ABCDEF';
    }
}