I have successfully added an admin controller which extends Mage_Adminhtml_Controller_Action
and works, now I am trying to use a block and template.
I expect to see the text "text here", but I don't see any text, I see the Magento admin header/footer with a blank area, at this URL: http://127.0.0.1/magento2/index.php/admin/c2/index/key/f5b1fd39ee6e77040cb4c6fbe7340ffd/ (Obviously, the link is a localhost link, but I've shown it for verification!)
My namespace is NS1
My module is Component Management
Here's my files.
app/code/local/NS1/ComponentManagement/controllers/c2Controller.php
<?php
class NS1_ComponentManagement_c2Controller extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
--
app/code/local/NS1/ComponentManagement/Block/Adminhtml/MyBlock.php
<?php
class NS1_ComponentManagement_Block_Adminhtml_ComponentManagement extends Mage_Adminhtml_Block_Template
{
public function methodblock()
{
return 'text here';
}
}
--
app/design/adminhtml/NS1/ComponentManagement/template/company.php
<?php
echo $this->methodblock();
--
app/design/adminhtml/NS1/ComponentManagement/layout/adminhtml.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<mymodulename_adminhtml_mymodulename_index>
<reference name="content">
<block type="NS1_ComponentManagement/adminhtml_componentmanagement" name="NS1.ComponentManagement" template="company.phtml" />
</reference>
</mymodulename_adminhtml_mymodulename_index>
</layout>
--
app/code/local/NS1/ComponentManagement/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<NS1_ComponentManagement>
<version>0.0.1</version>
</NS1_ComponentManagement>
</modules>
<frontend>
<routers>
<routeurfrontend>
<use>standard</use>
<args>
<module>NS1_ComponentManagement</module>
<frontName>test</frontName>
</args>
</routeurfrontend>
</routers>
<layout>
<updates>
<ComponentManagement>
<file>test.xml</file>
</ComponentManagement>
</updates>
</layout>
</frontend>
<global>
<blocks>
<ComponentManagement>
<class>NS1_ComponentManagement_Block</class>
</ComponentManagement>
</blocks>
<helpers>
<ComponentManagement>
<class>NS1_ComponentManagement_Helper</class>
</ComponentManagement>
</helpers>
</global>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<NS1_ComponentManagement after="Mage_Adminhtml">NS1_ComponentManagement</NS1_ComponentManagement>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
--