I am trying to create a simple hello world module, I am able to successfully create and install the module but for some reason, my screen is showing up blank. But if I echo
something in controller
it shows up. Can anyone help me where exactly I am going wrong? Below is my code.
I have been following this Tutorials
-app
-code
-KK
-OneStepCheckOut
-Block
--Main.php
-Controller
-OneStepCheckOut
--BillingAddress.php
-etc
--module.xml
-frontend
--routes.xml
-view
-frontend
-layout
--oneStepCheckOut_oneStepCheckOut_billingAddress.xml
-templates
--content.phtml
--registration.php
Controller:-
<?php
namespace kk\OneStepCheckout\Controller\OneStepCheckout;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\Context;
class BillingAddress extends \Magento\Framework\App\Action\Action
{
/**
* @var PageFactory
*/
protected $pageFactory;
public function __construct(Context $context, PageFactory $pageFactory)
{
$this->pageFactory = $pageFactory;
return parent::__construct($context);
}
public function execute()
{
// echo "In controller";
$page_object = $this->pageFactory->create();
return $page_object;
}
}
?>
oneStepCheckOut_oneStepCheckOut_billingAddress.xml:-
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="empty"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block
template="kk_OneStepCheckOut::content.phtml"
class="kk\OneStepCheckOut\Block\Main"
name="oneStepCheckOut" />
</referenceContainer>
</body>
</page>
Main.php:-
<?php
namespace kk\OneStepCheckOut\Block;
class Main extends \Magento\Framework\View\Element\Template
{
public function _prepareLayout()
{
return parent::_prepareLayout();
}
}
?>
Content.phtml:-
<h1><?php echo "hello world"; ?></h1>
routes.xml:-
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<router id="standard">
<route id="oneStepCheckOut" frontName="oneStepCheckOut">
<module name="kk_OneStepCheckOut" />
</route>
</router>
</config>
module.xml:-
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="kk_OneStepCheckOut" setup_version="0.0.1" />
</config>
change
oneStepCheckOut_oneStepCheckOut_billingAddress.xml` toonestepcheckout_onestepcheckout_billingaddress.xml