I have a custom controller which I'm trying to get a block rendered.
Company/Module/Controller/Index/Index.php
<?php
namespace Company\Module\Controller\Index;
use Magento\Framework\App\Action\Action;
use Magento\Framework\Controller\ResultFactory;
class Index extends Action
{
public function execute()
{
return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
}
}
Company/Module/Block/Hello.php
<?php
namespace Company\Module\Block;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
class Hello extends Template
{
}
Company/Module/etc/frontend/routes.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="testing_hello" frontName="testing">
<module name="Company_Module"/>
</route>
</router>
</config>
Company/Module/view/frontend/layout/testing_index_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block name="custom.name" class="Company\Module\Block\Hello" template="testing.phtml"/>
</referenceContainer>
</body>
</page>
Company/Module/view/frontend/templates/testing.phtml
<h2>Hello World</h2>
For some reason I don't see <h2>Hello World</h2>
I just see blank / empty content area but the rest of the page is loaded correctly.
I'll really appreciate any help on this.