I have created custom pages a lot of times, but never face such issue. I have tried 'echo' in controller action, it is working. But all this time the layout file is not loading for that page.
Here are my code files.
Controller/Customer/Test.php
class Test extends \Magento\Framework\App\Action\Action
{
protected $_pageFactory;
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $pageFactory)
{
$this->_pageFactory = $pageFactory;
return parent::__construct($context);
}
public function execute()
{
$page = $this->_pageFactory->create();
return $page;
}
}
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="orderbysku" frontName="orderbysku">
<module name="Vendor_Module" />
</route>
</router>
</config>
view/frontend/layout/orderbysku_customer_test.xml
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Magento\Framework\View\Element\Template" name="helloworld_index_index" template="Vendor_Module::index.phtml" />
</referenceContainer>
</body>
</page>
Any kind of help is appreciated, i'm really having a hard time to figure it out.
Best Answer
1. Create registration.php in app/code/Vendor/Module
2. Create module.xml in app/code/Vendor/Module/etc
3. Create routes.xml in app/code/Vendor/Module/etc/frontend
4.Create Test.php in app/code/Vendor/Module/Controller/Customer
5. Create orderbysku_customer_test.xml in app/code/Vendor/Module/view/frontend/layout
6. Create index.phtml in app/code/Vendor/Module/view/frontend/templates