etc/frontend/routes.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">
<router id="standard">
<route id="promotion" frontName="promotion">
<module name="Company_Promotion" />
</route>
</router>
</config>
Controller/Index/Index.php
<?php
namespace Company\Promotion\Controller\Index;
class Index extends \Magento\Framework\App\Action\Action
{
public function execute()
{
$this->_view->loadLayout();
$this->_view->getLayout()->initMessages();
$this->_view->renderLayout();
}
}
view/frontend/layout/promotion_index_index.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<head>
<title>Titlename</title>
</head>
<body>
<referenceContainer name="sidebar.main">
<block class="Company\Promotion\Block\Index\Sidebar" name="promotion_index_sidebar" before="-" template="Company_Promotion::promotion_index_sidebar.phtml"/>
</referenceContainer>
<referenceContainer name="content">
<block class="Company\Promotion\Block\Index\Index" name="promotion_index_index" template="Company_Promotion::promotion_index_index.phtml"/>
</referenceContainer>
</body>
</page>
Block/Index/Index.php
<?php
namespace Company\Promotion\Block\Index;
class Index extends \Magento\Framework\View\Element\Template {
public function __construct(\Magento\Catalog\Block\Product\Context $context, array $data = []) {
parent::__construct($context, $data);
}
protected function _prepareLayout()
{
return parent::_prepareLayout();
}
}
view/frontend/templates/promotion_index_index.phtml
You content goes here
$this->_pageFactory->create();
this i think..pls refer mageplaza.com/magento-2-module-development/…