3

I have created new module but it is not working.Please Help me on this.

registration

<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Outdoor_Configurator', __DIR__ ); 

Module

<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Outdoor_Configurator" setup_version="1.0.0"> <sequence> <module name="Magento_Backend"/> <module name="Magento_Sales"/> <module name="Magento_Quote"/> <module name="Magento_Checkout"/> <module name="Magento_Cms"/> </sequence> </module> 

routes

<?xml version="1.0"?> <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="testconfigurator" frontName="testconfigurator"> <module name="Outdoor_Configurator" /> </route> </router> 

Controller

<?php namespace Vendor\ModuleName\Controller\Index; class BuiltCatCollection extends \Magento\Framework\App\Action\Action { /** @var \Magento\Framework\View\Result\Page */ protected $resultPageFactory; /** * @param \Magento\Framework\App\Action\Context $context */ public function __construct(\Magento\Framework\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $resultPageFactory) { $this->resultPageFactory = $resultPageFactory; parent::__construct($context); } /** * Blog Index, shows a list of recent blog posts. * * @return \Magento\Framework\View\Result\PageFactory */ public function execute() { $resultPage = $this->resultPageFactory->create(); $resultPage->getConfig()->getTitle()->prepend(__('Custom Front View')); return $resultPage; } 

}

Block

<?php namespace Vendor\ModuleName\Block\Index; class BuiltInfo extends \Magento\Framework\View\Element\Template { public function _prepareLayout() { return parent::_prepareLayout(); } } 

Layout

<?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 class="Vendor\ModuleName\Block\Index\BuiltInfo" name="outdoor_configurator" template="Outdoor_Configurator::builtcatcolinfo.phtml"></block> </referenceContainer> </body> 

Template

<span style="font-weight: 400;">This is custom front view.</span> 
5
  • run php bin/magento mo:s to know if the module is registered and enabled. If not run php bin/magento s:up to register and php bin/magento mo:e Vendor_Module to enable it Commented Jun 28, 2019 at 12:46
  • Did you create registration.php ?? Commented Jun 28, 2019 at 12:47
  • I have checked module is enabled @VivekKumar Commented Jun 28, 2019 at 12:53
  • I have updated regitration code. Please check @RaviSoni Commented Jun 28, 2019 at 12:53
  • I have added my answer for your module. Please check where you miss. Commented Jun 28, 2019 at 12:54

2 Answers 2

1

You should create your module like this.

registration.php

 <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Outdoor_Configurator', __DIR__ ); 

etc/module.xml

<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Outdoor_Configurator" setup_version="1.0.0"> <sequence> <module name="Magento_Backend"/> <module name="Magento_Sales"/> <module name="Magento_Quote"/> <module name="Magento_Checkout"/> <module name="Magento_Cms"/> </sequence> </module> </config> 

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="configurator" frontName="configurator"> <module name="Outdoor_Configurator" /> </route> </router> </config> 

Block/Index/Index.php

<?php namespace Outdoor\Configurator\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(); } } 

Controller/Index/Index.php

<?php namespace Outdoor\Configurator\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/templates/index/configurator_index_index.phtml

Hello Demo Page 

view/frontend/layout/configurator_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="Outdoor\Configurator\Block\Index\Sidebar" name="configurator_index_sidebar" before="-" template="Outdoor_Configurator::configurator_index_sidebar.phtml"/> </referenceContainer> <referenceContainer name="content"> <block class="Outdoor\Configurator\Block\Index\Index" name="configurator_index_index" template="Outdoor_Configurator::configurator_index_index.phtml"/> </referenceContainer> </body> </page> 

Please check Now I have updated all code, with file name also.

13
  • Ok, I will check and update you. Commented Jun 28, 2019 at 12:58
  • I have created same module but not working. got the 404 error. Commented Jun 28, 2019 at 13:15
  • Can i share you zip file? Commented Jun 28, 2019 at 13:16
  • yes, i can, but how ? Commented Jun 28, 2019 at 13:18
  • I will share you download link. Commented Jun 28, 2019 at 13:21
4

There are a few problems in your module:

  1. You have used Outdoor_Configurator in module.xml but in Controller, Block, and layout you have used Vendor_Module.

  2. registration.php is missing from the code you have shared.

  3. You have not mentioned the file names and their paths. There may be a problem in the file naming convention.

Update:

Problems found in module shared at https://transfernow.net/813mi1m90ghk.

  • The controller file name is Builtcatcollection.php.php, which is wrong. Notice .php twice.
  • Code under block file is the same as in the controller file.
  • Folder name View should be view (small case).
  • The code under layout file is wrong.

Instead of:

<block class="Codism\Configurator\Block\Index\Builtcatcollection" name="index.builtcatcollection" template="Outdoor_Configurator::index/builtcatcollection.phtml"/> 

it should be like:

<block class="Outdoor\Configurator\Block\Index\Builtcatcollection" name="index.builtcatcollection" template="Outdoor_Configurator::index/builtcatcollection.phtml"/> 
13
  • I have updated regitration code. Please check Commented Jun 28, 2019 at 12:53
  • @MasudShaikh, please read the first point. You have used wrong names in Controller, Block and layout files. Commented Jun 28, 2019 at 13:22
  • I have created module under Codism folder and I have gave module name Outdoor_Configurator. I think my module name should be Codism_Configurator right? Commented Jun 28, 2019 at 13:27
  • It should be either Outdoor_Configurator or Codism_Configurator. Whatever name you use, it should be same at all places. Commented Jun 28, 2019 at 13:30
  • Controller file name in your module is also wrong (Builtcatcollection.php.php). Commented Jun 28, 2019 at 13:33

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.