To show a phtml at layout, you need to add a reference block name <refernece name="Parent_Block_name_At_Layout">
Also, your block is not closed, use /
or </block>
to close block.
Or you need to set your block name = root
instead of templateBlock
Basically...
<?xml version="1.0"?>
<layout version="1.0">
<adminhtml_adminhello_index>
<block type="core/template" name="root" template="adminhello/index.phtml"/>
</adminhtml_adminhello_index>
</layout>
Or
<?xml version="1.0"?>
<layout version="1.0">
<adminhtml_adminhello_index>
<reference name="content">
<block type="core/template" name="templateBlock" template="adminhello/index.phtml"/>
</reference>
</adminhtml_adminhello_index>
</layout>
If your Magento version is 1.9.2.2 or less and have applied Magento patch supee-6788, you need to change your url process.
If you have adminhtml.xml
for this extension, you need to give permission to access the page.
So, go to System
> Permissions
> Users
. select your user and save.
having some issues setting up admin routing.
As per the Magento routing, The router is looking for /manufacturer/grid/Index not manufacturer/grid.
This means admin Controller should be placed root\app\code\Amrita\Manufacturer\Controller\Adminhtml\Grid\Index.php
Please refer the code added for quick reference.
\app\code\Amrita\Manufacturer\etc\adminhtml\routes.xml
<router id="admin">
<route id="manufacturer" frontName="manufacturer">
<module name="Amrita_Manufacturer" before="Magento_Backend" />
</route>
</router>
\app\code\Amrita\Manufacturer\etc\adminhtml\menu.xml
<menu>
<add id="Amrita_Manufacturer::amrita_manufacturergrid" title="Manufacturers" module="Amrita_Manufacturer" parent="" sortOrder="20" dependsOnModule="Amrita_Manufacturer" action="manufacturer/grid" resource="Amrita_Manufacturer::amrita_manufacturergrid"/>
</menu>
\app\code\Amrita\Manufacturer\Controller\Adminhtml\Grid\Index.php
namespace Amrita\Manufacturer\Controller\Adminhtml\Grid;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
class Index extends \Magento\Backend\App\Action
{
/**
* @var PageFactory
*/
protected $resultPageFactory;
/**
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory
) {
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
}
public function execute()
{
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->resultPageFactory->create();
return $resultPage;
}
}
\app\code\Amrita\Manufacturer\view\adminhtml\layout\manufacturer_grid_index.xml
<body>
<referenceContainer name="content">
<block class="Amrita\Manufacturer\Block\Adminhtml\Manufacturer\Grid" name="manufacturer_grid" template="manufacturer\grid.phtml">
</block>
</referenceContainer>
</body>
\app\code\Amrita\Manufacturer\Block\Adminhtml\Manufacturer\Grid.php
namespace Amrita\Manufacturer\Block\Adminhtml\Manufacturer;
class Grid extends \Magento\Backend\Block\Template
{
}
Make the template as well as,
Hope this helps.
Best Answer
The starting point of displaying the content for your controller would be the following code from the Alan Storm's article
As you can see the controller renders a Layout. So you have to create such a layout. In module's config.xml please define layout file
Place adminhello.xml file to app/design/adminhtml/default/default/layout. It should contain the following code
Create your template app/design/adminhtml/default/default/template/adminhello/hello.phtml and put any code there.
It is the simplest way to display the content of phtml template by requesting your controller. For more detailed instructions please refer to
http://alanstorm.com/layouts_blocks_and_templates
and Magento Extension Developer's Guide