When run the custom module getting 404 error. Anyone, please help me.
app/code/Tychons/Registration/Block/Index.php
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Tychons\Registration\Block;
use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\ObjectManagerInterface;
class Index extends \Magento\Framework\View\Element\Template
{
protected $customerSession;
protected $storeManager;
protected $_object;
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
public function __construct(Context $context,ObjectManagerInterface $interface,array $data = []){
$this->_object = $interface;
//$this->storeManager = $storeManager;
$this->storeManager = $context->getStoreManager();
parent::__construct($context, $data);
}
public function getBaseUrl()
{
return $this->storeManager->getStore()->getBaseUrl();
}
}
app/code/Tychons/Registration/Controller/Verification.php
<?php
namespace Tychons\Registration\Controller;
use Magento\Framework\Controller\ResultFactory;
class Verification extends \Magento\Framework\App\Action\Action {
public function execute() {
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$resultPage->getConfig()->getTitle()->set(__('Email Verification'));
return $resultPage;
}
}
app/code/Tychons/Registration/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="verification" frontName="verification">
<module name="Tychons_Registration" />
</route>
</router>
</config>
app/code/Tychons/Registration/view/frontend/layout/registration_verification.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="page.main.title" as="top" remove="true">
<action method="setPageTitle">
<argument translate="true" name="title" xsi:type="string">Verification</argument>
</action>
</referenceBlock>
<referenceContainer name="content">
<block class="Tychons\Registration\Block\Index" name="verification" template="Tychons_Registration::verification.phtml" after='page.main.title' cacheable="false">
</block>
</referenceContainer>
</body>
</page>
app/code/Tychons/Registration/view/frontend/templates/verification.phtml
<?php echo "verificatiob page"; ?>
app/code/Tychons/Registration/registration.php
<?php
/**
* Module configuration
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Tychons_Registation',
__DIR__
);
app/code/Tychons/Registration/etc/module.xml
<?xml version="1.0"?>
<!--
/**
* Module configuration.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Tychons_Registration" setup_version="1.0.0" />
</config>
module.xml
andregistration.php
files? – Khoa TruongDinh Apr 4 '18 at 7:11Tychons/Registration/view/frontend/layout/registration_verification.xml
andapp/code/Tychons/Registration/Controller/Verification.php
are wrong. Please read my answer careful. – Khoa TruongDinh Apr 4 '18 at 9:15